Stuck on a Problem because I don't understand
- arholly
-
Topic Author
- Offline
- Senior Member
Less
More
- Posts: 40
- Thank you received: 0
12 May 2015 18:57 #1
by arholly
Stuck on a Problem because I don't understand was created by arholly
I was wondering if you might be able to help me with something. I've been plugging along on my code and making good progress but I'm stuck on something.
This is the code:The above shows the old and the new code (code I want to use). I've used the CampaignWorld code elsewhere and I know it works, but when I go to compile it, it's giving me this error message:
This is CampaignWorld:
What is going wrong and how can I fix it? Any help you can provide would be great.
This is the code:
// OLC_CONFIG(d)->play.campaign == CAMPAIGN_FORGOTTEN_REALMS ? "Forgotten Realms" : "Dragonlance: Age of Legends",
OLC_CONFIG(d)->play.campaign == CampaignWorld[CONFIG_CAMPAIGN], //<----Line 830
cedit.c:830: warning: comparison between pointer and integer
cedit.c:840: warning: format â%sâ expects type âchar *â, but argument 24 has type âintâ
This is CampaignWorld:
const char *CampaignWorld[] =
{
"Unknown - Alert Admin",
"Faerun",
"Krynn",
"Golarion"
};
What is going wrong and how can I fix it? Any help you can provide would be great.
Please Log in or Create an account to join the conversation.
- plamzi
-
- Offline
- Administrator
Less
More
- Posts: 285
- Thank you received: 42
13 May 2015 02:49 #2
by plamzi
Replied by plamzi on topic Stuck on a Problem because I don't understand
What you're seeing is the syntax [condition] ? [if true] : [if false]. The original statement means, "if campaign matches exactly the constant / macro, return static string "Forgotten Realms", otherwise return "Dragonlance", etc.
When you remove the stuff after ?, you can't keep the condition / comparison (==). If you are passing the result to a string building function, then I suspect what you need there is simply:
When you remove the stuff after ?, you can't keep the condition / comparison (==). If you are passing the result to a string building function, then I suspect what you need there is simply:
CampaignWorld[CONFIG_CAMPAIGN],
Please Log in or Create an account to join the conversation.
- arholly
-
Topic Author
- Offline
- Senior Member
Less
More
- Posts: 40
- Thank you received: 0
13 May 2015 12:02 #3
by arholly
Replied by arholly on topic Stuck on a Problem because I don't understand
Thanks. I did get it figured out.
Please Log in or Create an account to join the conversation.