Spellforce-Spell-framework
Loading...
Searching...
No Matches
Custom Campaign JSON Loader

Turns a campaign JSON file into an SFSF_CampaignDef. More...

Classes

struct  CampaignJson
 Parse result: the definition plus which keys were actually present. More...

Macros

#define JSMN_STATIC
#define JSMN_PARENT_LINKS

Enumerations

enum  CampaignFieldKey {
  CAMPAIGN_FIELD_UNKNOWN = 0 , CAMPAIGN_FIELD_NAME , CAMPAIGN_FIELD_CAMPAIGN_NAME_ID , CAMPAIGN_FIELD_DESCRIPTION ,
  CAMPAIGN_FIELD_AUTHOR , CAMPAIGN_FIELD_START_MAP , CAMPAIGN_FIELD_TUTORIAL_MAP , CAMPAIGN_FIELD_CAMPAIGN_FOLDER ,
  CAMPAIGN_FIELD_STARTERKIT , CAMPAIGN_FIELD_INTRO_VIDEO , CAMPAIGN_FIELD_AVATAR_TYPE
}

Functions

bool parse_campaign_json_file (const char *path, CampaignJson *out_campaign)
 Reads and parses a campaign JSON file.

Detailed Description

Turns a campaign JSON file into an SFSF_CampaignDef.

The loader only parses - it does not validate meaning or register anything. Presence flags are reported back so the caller (sf_campaign_module.c) can decide what is required and attribute the failures to a mod.

Macro Definition Documentation

◆ JSMN_PARENT_LINKS

#define JSMN_PARENT_LINKS

Definition at line 15 of file sf_campaign_loader.c.

◆ JSMN_STATIC

#define JSMN_STATIC

Definition at line 14 of file sf_campaign_loader.c.

Enumeration Type Documentation

◆ CampaignFieldKey

Enumerator
CAMPAIGN_FIELD_UNKNOWN 
CAMPAIGN_FIELD_NAME 
CAMPAIGN_FIELD_CAMPAIGN_NAME_ID 
CAMPAIGN_FIELD_DESCRIPTION 
CAMPAIGN_FIELD_AUTHOR 
CAMPAIGN_FIELD_START_MAP 
CAMPAIGN_FIELD_TUTORIAL_MAP 
CAMPAIGN_FIELD_CAMPAIGN_FOLDER 
CAMPAIGN_FIELD_STARTERKIT 
CAMPAIGN_FIELD_INTRO_VIDEO 
CAMPAIGN_FIELD_AVATAR_TYPE 

Definition at line 44 of file sf_campaign_loader.h.

Function Documentation

◆ parse_campaign_json_file()

bool parse_campaign_json_file ( const char * path,
CampaignJson * out_campaign )

Reads and parses a campaign JSON file.

Parameters
pathFull path to the .json file.
out_campaignZeroed and filled on success.
Returns
false when the file is unreadable or is not a single JSON object.

Definition at line 198 of file sf_campaign_loader.c.

Here is the call graph for this function: