Load / save functions for weapon pickups.
This commit is contained in:
parent
234f8fe73c
commit
db9cddb7e8
|
@ -24,6 +24,8 @@ static void (*superTick)(void);
|
|||
static void init(void);
|
||||
static void tick(void);
|
||||
static void touch(Entity *other);
|
||||
static void load(cJSON *root);
|
||||
static void save(cJSON *root);
|
||||
|
||||
Entity *initWeaponPickup(void)
|
||||
{
|
||||
|
@ -38,6 +40,8 @@ Entity *initWeaponPickup(void)
|
|||
i->init = init;
|
||||
i->tick = tick;
|
||||
i->touch = touch;
|
||||
i->load = load;
|
||||
i->save = save;
|
||||
|
||||
return (Entity*)i;
|
||||
}
|
||||
|
@ -100,3 +104,18 @@ static void touch(Entity *other)
|
|||
game.stats[STAT_WEAPONS_PICKED_UP]++;
|
||||
}
|
||||
}
|
||||
|
||||
static void load(cJSON *root)
|
||||
{
|
||||
Item *i;
|
||||
|
||||
i = (Item*)self;
|
||||
|
||||
i->weaponType = lookup(cJSON_GetObjectItem(root, "weaponType")->valuestring);
|
||||
i->provided = cJSON_GetObjectItem(root, "provided")->valueint;
|
||||
}
|
||||
|
||||
static void save(cJSON *root)
|
||||
{
|
||||
/* boss missions, only - not going to worry about saving these */
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
|
||||
#include "../../common.h"
|
||||
#include "../../json/cJSON.h"
|
||||
|
||||
extern void playSound(int snd, int ch);
|
||||
extern void setGameplayMessage(int type, char *format, ...);
|
||||
|
@ -27,6 +28,7 @@ extern void pickupItem(void);
|
|||
extern int touchedPlayer(Entity *e);
|
||||
extern const char *getWeaponName(int i);
|
||||
extern Entity *initConsumable(void);
|
||||
extern int lookup(char *name);
|
||||
|
||||
extern Entity *self;
|
||||
extern Game game;
|
||||
|
|
|
@ -39,6 +39,9 @@ void initLookups(void)
|
|||
addLookup("DOOR_OPEN", DOOR_OPEN);
|
||||
addLookup("DOOR_CLOSED", DOOR_CLOSED);
|
||||
|
||||
addLookup("WPN_PLASMA", WPN_PLASMA);
|
||||
addLookup("WPN_SPREAD", WPN_SPREAD);
|
||||
|
||||
addLookup("CONTROL_LEFT", CONTROL_LEFT);
|
||||
addLookup("CONTROL_RIGHT", CONTROL_RIGHT);
|
||||
addLookup("CONTROL_UP", CONTROL_UP);
|
||||
|
|
Loading…
Reference in New Issue