Allow flags in missions to be added to existing entity flags, or replace them completely.
This commit is contained in:
parent
6b06b2a431
commit
4fbdcd0af6
|
@ -56,7 +56,7 @@ void initBulletDefs(void)
|
|||
def->damage = cJSON_GetObjectItem(node, "damage")->valueint;
|
||||
def->texture = getTexture(cJSON_GetObjectItem(node, "textureName")->valuestring);
|
||||
def->sound = lookup(cJSON_GetObjectItem(node, "sound")->valuestring);
|
||||
def->flags = flagsToLong(cJSON_GetObjectItem(node, "flags")->valuestring);
|
||||
def->flags = flagsToLong(cJSON_GetObjectItem(node, "flags")->valuestring, NULL);
|
||||
|
||||
SDL_QueryTexture(def->texture, NULL, NULL, &def->w, &def->h);
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ extern void blitRotated(SDL_Texture *texture, int x, int y, int angle);
|
|||
extern int collision(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2);
|
||||
extern void damageFighter(Entity *f, int damage, long flags);
|
||||
extern void playBattleSound(int id, int x, int y);
|
||||
extern long flagsToLong(char *flags);
|
||||
extern long flagsToLong(char *flags, int *add);
|
||||
extern long lookup(char *name);
|
||||
extern char *readFile(char *filename);
|
||||
extern float getAngle(int x1, int y1, int x2, int y2);
|
||||
|
|
|
@ -363,14 +363,14 @@ static void loadComponents(Entity *parent, cJSON *components)
|
|||
|
||||
SDL_QueryTexture(e->texture, NULL, NULL, &e->w, &e->h);
|
||||
|
||||
if (cJSON_GetObjectItem(component, "aiFlags"))
|
||||
{
|
||||
e->aiFlags = flagsToLong(cJSON_GetObjectItem(component, "aiFlags")->valuestring);
|
||||
}
|
||||
|
||||
if (cJSON_GetObjectItem(component, "flags"))
|
||||
{
|
||||
e->flags = flagsToLong(cJSON_GetObjectItem(component, "flags")->valuestring);
|
||||
e->flags = flagsToLong(cJSON_GetObjectItem(component, "flags")->valuestring, NULL);
|
||||
}
|
||||
|
||||
if (cJSON_GetObjectItem(component, "aiFlags"))
|
||||
{
|
||||
e->aiFlags = flagsToLong(cJSON_GetObjectItem(component, "aiFlags")->valuestring, NULL);
|
||||
}
|
||||
|
||||
e->systemPower = 100;
|
||||
|
@ -419,14 +419,14 @@ static void loadGuns(Entity *parent, cJSON *guns)
|
|||
e->missiles = cJSON_GetObjectItem(gun, "missiles")->valueint;
|
||||
}
|
||||
|
||||
if (cJSON_GetObjectItem(gun, "aiFlags"))
|
||||
{
|
||||
e->aiFlags = flagsToLong(cJSON_GetObjectItem(gun, "aiFlags")->valuestring);
|
||||
}
|
||||
|
||||
if (cJSON_GetObjectItem(gun, "flags"))
|
||||
{
|
||||
e->flags = flagsToLong(cJSON_GetObjectItem(gun, "flags")->valuestring);
|
||||
e->flags = flagsToLong(cJSON_GetObjectItem(gun, "flags")->valuestring, NULL);
|
||||
}
|
||||
|
||||
if (cJSON_GetObjectItem(gun, "aiFlags"))
|
||||
{
|
||||
e->aiFlags = flagsToLong(cJSON_GetObjectItem(gun, "aiFlags")->valuestring, NULL);
|
||||
}
|
||||
|
||||
SDL_QueryTexture(e->texture, NULL, NULL, &e->w, &e->h);
|
||||
|
@ -471,7 +471,7 @@ static void loadEngines(Entity *parent, cJSON *engines)
|
|||
|
||||
if (cJSON_GetObjectItem(engine, "flags"))
|
||||
{
|
||||
e->flags = flagsToLong(cJSON_GetObjectItem(engine, "flags")->valuestring);
|
||||
e->flags = flagsToLong(cJSON_GetObjectItem(engine, "flags")->valuestring, NULL);
|
||||
}
|
||||
|
||||
SDL_QueryTexture(e->texture, NULL, NULL, &e->w, &e->h);
|
||||
|
|
|
@ -32,7 +32,7 @@ extern float getAngle(int x1, int y1, int x2, int y2);
|
|||
extern SDL_Texture *getTexture(char *filename);
|
||||
extern char *readFile(char *filename);
|
||||
extern char *getFileLocation(char *filename);
|
||||
extern long flagsToLong(char *flags);
|
||||
extern long flagsToLong(char *flags, int *add);
|
||||
extern long lookup(char *name);
|
||||
extern void doAI(void);
|
||||
extern float getAngle(int x1, int y1, int x2, int y2);
|
||||
|
|
|
@ -649,12 +649,12 @@ static void loadFighterDef(char *filename)
|
|||
|
||||
if (cJSON_GetObjectItem(root, "flags"))
|
||||
{
|
||||
f->flags = flagsToLong(cJSON_GetObjectItem(root, "flags")->valuestring);
|
||||
f->flags = flagsToLong(cJSON_GetObjectItem(root, "flags")->valuestring, NULL);
|
||||
}
|
||||
|
||||
if (cJSON_GetObjectItem(root, "aiFlags"))
|
||||
{
|
||||
f->aiFlags = flagsToLong(cJSON_GetObjectItem(root, "aiFlags")->valuestring);
|
||||
f->aiFlags = flagsToLong(cJSON_GetObjectItem(root, "aiFlags")->valuestring, NULL);
|
||||
}
|
||||
|
||||
f->separationRadius = MAX(f->w, f->h);
|
||||
|
|
|
@ -39,7 +39,7 @@ extern void adjustObjectiveTargetValue(char *name, int type, int amount);
|
|||
extern void attachRope(void);
|
||||
extern char *readFile(char *filename);
|
||||
extern long lookup(char *name);
|
||||
extern long flagsToLong(char *flags);
|
||||
extern long flagsToLong(char *flags, int *add);
|
||||
extern void addShieldSplinterEffect(Entity *ent);
|
||||
extern void completeMission(void);
|
||||
extern void runScriptFunction(char *format, ...);
|
||||
|
|
|
@ -201,7 +201,7 @@ static void loadFighters(cJSON *node)
|
|||
Entity *f;
|
||||
char **types, *name, *groupName, *type;
|
||||
int side, scatter, number, active;
|
||||
int i, numTypes;
|
||||
int i, numTypes, addFlags, addAIFlags;
|
||||
long flags, aiFlags;
|
||||
float x, y;
|
||||
|
||||
|
@ -251,12 +251,12 @@ static void loadFighters(cJSON *node)
|
|||
|
||||
if (cJSON_GetObjectItem(node, "flags"))
|
||||
{
|
||||
flags = flagsToLong(cJSON_GetObjectItem(node, "flags")->valuestring);
|
||||
flags = flagsToLong(cJSON_GetObjectItem(node, "flags")->valuestring, &addFlags);
|
||||
}
|
||||
|
||||
if (cJSON_GetObjectItem(node, "aiFlags"))
|
||||
{
|
||||
aiFlags = flagsToLong(cJSON_GetObjectItem(node, "aiFlags")->valuestring);
|
||||
aiFlags = flagsToLong(cJSON_GetObjectItem(node, "aiFlags")->valuestring, &addAIFlags);
|
||||
}
|
||||
|
||||
for (i = 0 ; i < number ; i++)
|
||||
|
@ -275,12 +275,30 @@ static void loadFighters(cJSON *node)
|
|||
|
||||
if (flags != -1)
|
||||
{
|
||||
f->flags = flags;
|
||||
if (addFlags)
|
||||
{
|
||||
f->flags |= flags;
|
||||
}
|
||||
else
|
||||
{
|
||||
f->flags = flags;
|
||||
|
||||
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_WARN, "Flags for '%s' (%s) replaced", f->name, f->defName);
|
||||
}
|
||||
}
|
||||
|
||||
if (aiFlags != -1)
|
||||
{
|
||||
f->aiFlags = aiFlags;
|
||||
if (addAIFlags)
|
||||
{
|
||||
f->aiFlags |= aiFlags;
|
||||
}
|
||||
else
|
||||
{
|
||||
f->aiFlags = aiFlags;
|
||||
|
||||
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_WARN, "AI Flags for '%s' (%s) replaced", f->name, f->defName);
|
||||
}
|
||||
}
|
||||
|
||||
if (name)
|
||||
|
@ -306,7 +324,7 @@ static void loadCapitalShips(cJSON *node)
|
|||
Entity *e;
|
||||
char **types, *name, *groupName, *type;
|
||||
int side, scatter, number, active;
|
||||
int i, numTypes;
|
||||
int i, numTypes, addFlags;
|
||||
long flags;
|
||||
float x, y;
|
||||
|
||||
|
@ -355,7 +373,7 @@ static void loadCapitalShips(cJSON *node)
|
|||
|
||||
if (cJSON_GetObjectItem(node, "flags"))
|
||||
{
|
||||
flags = flagsToLong(cJSON_GetObjectItem(node, "flags")->valuestring);
|
||||
flags = flagsToLong(cJSON_GetObjectItem(node, "flags")->valuestring, &addFlags);
|
||||
}
|
||||
|
||||
for (i = 0 ; i < number ; i++)
|
||||
|
@ -384,7 +402,16 @@ static void loadCapitalShips(cJSON *node)
|
|||
|
||||
if (flags != -1)
|
||||
{
|
||||
e->flags = flags;
|
||||
if (addFlags)
|
||||
{
|
||||
e->flags |= flags;
|
||||
}
|
||||
else
|
||||
{
|
||||
e->flags = flags;
|
||||
|
||||
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_WARN, "Flags for '%s' (%s) replaced", e->name, e->defName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -494,7 +521,7 @@ static void loadItems(cJSON *node)
|
|||
{
|
||||
Entity *e;
|
||||
char *name, *groupName, *type;
|
||||
int i, scatter, number, active;
|
||||
int i, scatter, number, active, addFlags;
|
||||
long flags;
|
||||
float x, y;
|
||||
|
||||
|
@ -537,7 +564,7 @@ static void loadItems(cJSON *node)
|
|||
|
||||
if (cJSON_GetObjectItem(node, "flags"))
|
||||
{
|
||||
flags = flagsToLong(cJSON_GetObjectItem(node, "flags")->valuestring);
|
||||
flags = flagsToLong(cJSON_GetObjectItem(node, "flags")->valuestring, &addFlags);
|
||||
}
|
||||
|
||||
if (cJSON_GetObjectItem(node, "active"))
|
||||
|
@ -561,7 +588,16 @@ static void loadItems(cJSON *node)
|
|||
|
||||
if (flags != -1)
|
||||
{
|
||||
e->flags = flags;
|
||||
if (addFlags)
|
||||
{
|
||||
e->flags |= flags;
|
||||
}
|
||||
else
|
||||
{
|
||||
e->flags = flags;
|
||||
|
||||
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_WARN, "Flags for '%s' (%s) replaced", e->name, e->defName);
|
||||
}
|
||||
}
|
||||
|
||||
e->x = x;
|
||||
|
|
|
@ -34,7 +34,7 @@ extern void endSectionTransition(void);
|
|||
extern void playMusic(char *filename);
|
||||
extern void stopMusic(void);
|
||||
extern void initPlayer(void);
|
||||
extern long flagsToLong(char *flags);
|
||||
extern long flagsToLong(char *flags, int *add);
|
||||
extern Entity *spawnWaypoint(void);
|
||||
extern void activateNextWaypoint(void);
|
||||
extern void selectWidget(const char *name, const char *group);
|
||||
|
|
|
@ -215,13 +215,18 @@ char *getFlagValues(char *prefix, long flags)
|
|||
return flagStr;
|
||||
}
|
||||
|
||||
long flagsToLong(char *flags)
|
||||
long flagsToLong(char *flags, int *add)
|
||||
{
|
||||
char *flag;
|
||||
long total;
|
||||
|
||||
total = 0;
|
||||
|
||||
if (add)
|
||||
{
|
||||
*add = (flags[0] == '+');
|
||||
}
|
||||
|
||||
flag = strtok(flags, "+");
|
||||
while (flag)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue