forked from github/server
parent
73a6b96bc7
commit
2d30d4cce6
|
@ -101,7 +101,7 @@ static int tolua_storage_tostring(lua_State * L)
|
|||
{
|
||||
gamedata *data = (gamedata *)tolua_tousertype(L, 1, 0);
|
||||
char name[64];
|
||||
_snprintf(name, sizeof(name), "<gamedata %p ver=%d>", data, data->version);
|
||||
_snprintf(name, sizeof(name), "<gamedata %p ver=%d>", (void *)data, data->version);
|
||||
lua_pushstring(L, name);
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -449,10 +449,10 @@ static void caldera_write(const trigger * t, struct storage *store)
|
|||
write_building_reference(b, store);
|
||||
}
|
||||
|
||||
static int caldera_read(trigger * t, struct storage *store)
|
||||
static int caldera_read(trigger * t, struct gamedata *data)
|
||||
{
|
||||
int rb =
|
||||
read_reference(&t->data.v, store, read_building_reference,
|
||||
read_reference(&t->data.v, data->store, read_building_reference,
|
||||
resolve_building);
|
||||
if (rb == 0 && !t->data.v) {
|
||||
return AT_READ_FAIL;
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <util/attrib.h>
|
||||
#include <util/base36.h>
|
||||
#include <util/event.h>
|
||||
#include <util/gamedata.h>
|
||||
#include <util/goodies.h>
|
||||
#include <util/resolve.h>
|
||||
|
||||
|
@ -47,10 +48,10 @@ static void xmasgate_write(const trigger * t, struct storage *store)
|
|||
WRITE_TOK(store, itoa36(b->no));
|
||||
}
|
||||
|
||||
static int xmasgate_read(trigger * t, struct storage *store)
|
||||
static int xmasgate_read(trigger * t, struct gamedata *data)
|
||||
{
|
||||
int bc =
|
||||
read_reference(&t->data.v, store, read_building_reference,
|
||||
read_reference(&t->data.v, data->store, read_building_reference,
|
||||
resolve_building);
|
||||
if (bc == 0 && !t->data.v) {
|
||||
return AT_READ_FAIL;
|
||||
|
|
|
@ -28,6 +28,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
/* util includes */
|
||||
#include <util/attrib.h>
|
||||
#include <util/event.h>
|
||||
#include <util/gamedata.h>
|
||||
#include <util/log.h>
|
||||
#include <util/resolve.h>
|
||||
#include <util/base36.h>
|
||||
|
@ -82,12 +83,13 @@ static void changefaction_write(const trigger * t, struct storage *store)
|
|||
write_faction_reference(td->faction->_alive ? td->faction : NULL, store);
|
||||
}
|
||||
|
||||
static int changefaction_read(trigger * t, struct storage *store)
|
||||
static int changefaction_read(trigger * t, gamedata *data)
|
||||
{
|
||||
variant var;
|
||||
changefaction_data *td = (changefaction_data *)t->data.v;
|
||||
read_reference(&td->unit, store, read_unit_reference, resolve_unit);
|
||||
var = read_faction_reference(store);
|
||||
|
||||
read_reference(&td->unit, data->store, read_unit_reference, resolve_unit);
|
||||
var = read_faction_reference(data->store);
|
||||
if (var.i == 0) {
|
||||
return AT_READ_FAIL;
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
/* util includes */
|
||||
#include <util/attrib.h>
|
||||
#include <util/event.h>
|
||||
#include <util/gamedata.h>
|
||||
#include <util/log.h>
|
||||
#include <util/resolve.h>
|
||||
#include <util/base36.h>
|
||||
|
@ -86,12 +87,12 @@ static void changerace_write(const trigger * t, struct storage *store)
|
|||
write_race_reference(td->irace, store);
|
||||
}
|
||||
|
||||
static int changerace_read(trigger * t, struct storage *store)
|
||||
static int changerace_read(trigger * t, gamedata *data)
|
||||
{
|
||||
changerace_data *td = (changerace_data *)t->data.v;
|
||||
read_reference(&td->u, store, read_unit_reference, resolve_unit);
|
||||
td->race = (const struct race *)read_race_reference(store).v;
|
||||
td->irace = (const struct race *)read_race_reference(store).v;
|
||||
read_reference(&td->u, data->store, read_unit_reference, resolve_unit);
|
||||
td->race = (const struct race *)read_race_reference(data->store).v;
|
||||
td->irace = (const struct race *)read_race_reference(data->store).v;
|
||||
return AT_READ_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
/* util includes */
|
||||
#include <util/attrib.h>
|
||||
#include <util/event.h>
|
||||
#include <util/gamedata.h>
|
||||
#include <util/log.h>
|
||||
#include <util/resolve.h>
|
||||
#include <util/base36.h>
|
||||
|
@ -68,10 +69,10 @@ static void clonedied_write(const trigger * t, struct storage *store)
|
|||
write_unit_reference(u, store);
|
||||
}
|
||||
|
||||
static int clonedied_read(trigger * t, struct storage *store)
|
||||
static int clonedied_read(trigger * t, gamedata *data)
|
||||
{
|
||||
int result =
|
||||
read_reference(&t->data.v, store, read_unit_reference, resolve_unit);
|
||||
read_reference(&t->data.v, data->store, read_unit_reference, resolve_unit);
|
||||
if (result == 0 && t->data.v == NULL) {
|
||||
return AT_READ_FAIL;
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
/* util includes */
|
||||
#include <util/attrib.h>
|
||||
#include <util/event.h>
|
||||
#include <util/gamedata.h>
|
||||
#include <util/log.h>
|
||||
#include <util/resolve.h>
|
||||
#include <util/base36.h>
|
||||
|
@ -93,30 +94,30 @@ static void createcurse_write(const trigger * t, struct storage *store)
|
|||
WRITE_INT(store, td->men);
|
||||
}
|
||||
|
||||
static int createcurse_read(trigger * t, struct storage *store)
|
||||
static int createcurse_read(trigger * t, gamedata *data)
|
||||
{
|
||||
createcurse_data *td = (createcurse_data *)t->data.v;
|
||||
char zText[128];
|
||||
float flt;
|
||||
|
||||
read_reference(&td->mage, store, read_unit_reference, resolve_unit);
|
||||
read_reference(&td->target, store, read_unit_reference, resolve_unit);
|
||||
read_reference(&td->mage, data->store, read_unit_reference, resolve_unit);
|
||||
read_reference(&td->target, data->store, read_unit_reference, resolve_unit);
|
||||
|
||||
READ_TOK(store, zText, sizeof(zText));
|
||||
READ_TOK(data->store, zText, sizeof(zText));
|
||||
td->type = ct_find(zText);
|
||||
READ_FLT(store, &flt);
|
||||
READ_FLT(data->store, &flt);
|
||||
td->vigour = flt;
|
||||
READ_INT(store, &td->duration);
|
||||
if (global.data_version < CURSEFLOAT_VERSION) {
|
||||
READ_INT(data->store, &td->duration);
|
||||
if (data->version < CURSEFLOAT_VERSION) {
|
||||
int n;
|
||||
READ_INT(store, &n);
|
||||
READ_INT(data->store, &n);
|
||||
td->effect = (float)n;
|
||||
}
|
||||
else {
|
||||
READ_FLT(store, &flt);
|
||||
READ_FLT(data->store, &flt);
|
||||
td->effect = flt;
|
||||
}
|
||||
READ_INT(store, &td->men);
|
||||
READ_INT(data->store, &td->men);
|
||||
return AT_READ_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
#include <util/attrib.h>
|
||||
#include <util/base36.h>
|
||||
#include <util/event.h>
|
||||
#include <util/gamedata.h>
|
||||
#include <util/log.h>
|
||||
#include <util/resolve.h>
|
||||
|
||||
|
@ -88,12 +89,12 @@ static void createunit_write(const trigger * t, struct storage *store)
|
|||
WRITE_INT(store, td->number);
|
||||
}
|
||||
|
||||
static int createunit_read(trigger * t, struct storage *store)
|
||||
static int createunit_read(trigger * t, gamedata *data)
|
||||
{
|
||||
createunit_data *td = (createunit_data *)t->data.v;
|
||||
variant var;
|
||||
int result = AT_READ_OK;
|
||||
var = read_faction_reference(store);
|
||||
var = read_faction_reference(data->store);
|
||||
if (var.i > 0) {
|
||||
td->f = findfaction(var.i);
|
||||
if (!td->f) {
|
||||
|
@ -105,13 +106,13 @@ static int createunit_read(trigger * t, struct storage *store)
|
|||
}
|
||||
// read_reference(&td->f, store, read_faction_reference, resolve_faction);
|
||||
|
||||
read_reference(&td->r, store, read_region_reference,
|
||||
read_reference(&td->r, data->store, read_region_reference,
|
||||
RESOLVE_REGION(global.data_version));
|
||||
td->race = (const struct race *)read_race_reference(store).v;
|
||||
td->race = (const struct race *)read_race_reference(data->store).v;
|
||||
if (!td->race) {
|
||||
result = AT_READ_FAIL;
|
||||
}
|
||||
READ_INT(store, &td->number);
|
||||
READ_INT(data->store, &td->number);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
/* util includes */
|
||||
#include <util/attrib.h>
|
||||
#include <util/event.h>
|
||||
#include <util/gamedata.h>
|
||||
#include <util/log.h>
|
||||
#include <util/resolve.h>
|
||||
|
||||
|
@ -72,14 +73,14 @@ static void gate_write(const trigger * t, struct storage *store)
|
|||
write_region_reference(r, store);
|
||||
}
|
||||
|
||||
static int gate_read(trigger * t, struct storage *store)
|
||||
static int gate_read(trigger * t, gamedata *data)
|
||||
{
|
||||
gate_data *gd = (gate_data *)t->data.v;
|
||||
|
||||
int bc =
|
||||
read_reference(&gd->gate, store, read_building_reference, resolve_building);
|
||||
read_reference(&gd->gate, data->store, read_building_reference, resolve_building);
|
||||
int rc =
|
||||
read_reference(&gd->target, store, read_region_reference,
|
||||
read_reference(&gd->target, data->store, read_region_reference,
|
||||
RESOLVE_REGION(global.data_version));
|
||||
|
||||
if (bc == 0 && rc == 0) {
|
||||
|
|
|
@ -28,6 +28,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
#include <util/attrib.h>
|
||||
#include <util/base36.h>
|
||||
#include <util/event.h>
|
||||
#include <util/gamedata.h>
|
||||
#include <util/log.h>
|
||||
#include <util/resolve.h>
|
||||
|
||||
|
@ -82,15 +83,15 @@ static void giveitem_write(const trigger * t, struct storage *store)
|
|||
WRITE_TOK(store, td->itype->rtype->_name);
|
||||
}
|
||||
|
||||
static int giveitem_read(trigger * t, struct storage *store)
|
||||
static int giveitem_read(trigger * t, gamedata *data)
|
||||
{
|
||||
giveitem_data *td = (giveitem_data *)t->data.v;
|
||||
char zText[128];
|
||||
|
||||
int result = read_reference(&td->u, store, read_unit_reference, resolve_unit);
|
||||
int result = read_reference(&td->u, data->store, read_unit_reference, resolve_unit);
|
||||
|
||||
READ_INT(store, &td->number);
|
||||
READ_TOK(store, zText, sizeof(zText));
|
||||
READ_INT(data->store, &td->number);
|
||||
READ_TOK(data->store, zText, sizeof(zText));
|
||||
td->itype = it_find(zText);
|
||||
assert(td->itype);
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
#include <util/attrib.h>
|
||||
#include <util/base36.h>
|
||||
#include <util/event.h>
|
||||
#include <util/gamedata.h>
|
||||
#include <util/log.h>
|
||||
#include <util/resolve.h>
|
||||
|
||||
|
@ -58,10 +59,10 @@ static void killunit_write(const trigger * t, struct storage *store)
|
|||
write_unit_reference(u, store);
|
||||
}
|
||||
|
||||
static int killunit_read(trigger * t, struct storage *store)
|
||||
static int killunit_read(trigger * t, gamedata *data)
|
||||
{
|
||||
int result =
|
||||
read_reference(&t->data.v, store, read_unit_reference, resolve_unit);
|
||||
read_reference(&t->data.v, data->store, read_unit_reference, resolve_unit);
|
||||
if (result == 0 && t->data.v == NULL) {
|
||||
return AT_READ_FAIL;
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
#include <util/attrib.h>
|
||||
#include <util/base36.h>
|
||||
#include <util/event.h>
|
||||
#include <util/gamedata.h>
|
||||
#include <util/log.h>
|
||||
#include <util/resolve.h>
|
||||
|
||||
|
@ -77,12 +78,12 @@ static void removecurse_write(const trigger * t, struct storage *store)
|
|||
WRITE_INT(store, td->curse ? td->curse->no : 0);
|
||||
}
|
||||
|
||||
static int removecurse_read(trigger * t, struct storage *store)
|
||||
static int removecurse_read(trigger * t, gamedata *data)
|
||||
{
|
||||
removecurse_data *td = (removecurse_data *)t->data.v;
|
||||
|
||||
read_reference(&td->target, store, read_unit_reference, resolve_unit);
|
||||
read_reference(&td->curse, store, read_int, resolve_curse);
|
||||
read_reference(&td->target, data->store, read_unit_reference, resolve_unit);
|
||||
read_reference(&td->curse, data->store, read_int, resolve_curse);
|
||||
|
||||
return AT_READ_OK;
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
#include <util/attrib.h>
|
||||
#include <util/base36.h>
|
||||
#include <util/event.h>
|
||||
#include <util/gamedata.h>
|
||||
#include <util/log.h>
|
||||
#include <util/resolve.h>
|
||||
#include <util/rng.h>
|
||||
|
@ -125,10 +126,10 @@ static void shock_write(const trigger * t, struct storage *store)
|
|||
}
|
||||
}
|
||||
|
||||
static int shock_read(trigger * t, struct storage *store)
|
||||
static int shock_read(trigger * t, gamedata *data)
|
||||
{
|
||||
int result =
|
||||
read_reference(&t->data.v, store, read_unit_reference, resolve_unit);
|
||||
read_reference(&t->data.v, data->store, read_unit_reference, resolve_unit);
|
||||
if (result == 0 && t->data.v == NULL) {
|
||||
return AT_READ_FAIL;
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
/* util includes */
|
||||
#include <util/attrib.h>
|
||||
#include <util/event.h>
|
||||
#include <util/gamedata.h>
|
||||
#include <util/log.h>
|
||||
|
||||
#include <storage.h>
|
||||
|
@ -72,11 +73,11 @@ static void timeout_write(const trigger * t, struct storage *store)
|
|||
write_triggers(store, td->triggers);
|
||||
}
|
||||
|
||||
static int timeout_read(trigger * t, struct storage *store)
|
||||
static int timeout_read(trigger * t, gamedata *data)
|
||||
{
|
||||
timeout_data *td = (timeout_data *)t->data.v;
|
||||
READ_INT(store, &td->timer);
|
||||
read_triggers(store, &td->triggers);
|
||||
READ_INT(data->store, &td->timer);
|
||||
read_triggers(data, &td->triggers);
|
||||
if (td->timer > 20) {
|
||||
trigger *tr = td->triggers;
|
||||
log_warning("there is a timeout lasting for another %d turns\n", td->timer);
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
/* util includes */
|
||||
#include <util/attrib.h>
|
||||
#include <util/event.h>
|
||||
#include <util/gamedata.h>
|
||||
#include <util/log.h>
|
||||
#include <util/resolve.h>
|
||||
|
||||
|
@ -48,10 +49,10 @@ static void unguard_write(const trigger * t, struct storage *store)
|
|||
write_building_reference((building *)t->data.v, store);
|
||||
}
|
||||
|
||||
static int unguard_read(trigger * t, struct storage *store)
|
||||
static int unguard_read(trigger * t, gamedata *data)
|
||||
{
|
||||
int rb =
|
||||
read_reference(&t->data.v, store, read_building_reference,
|
||||
read_reference(&t->data.v, data->store, read_building_reference,
|
||||
resolve_building);
|
||||
if (rb == 0 && !t->data.v) {
|
||||
return AT_READ_FAIL;
|
||||
|
|
|
@ -20,6 +20,7 @@ without prior permission by the authors of Eressea.
|
|||
#include <util/attrib.h>
|
||||
#include <util/base36.h>
|
||||
#include <util/event.h>
|
||||
#include <util/gamedata.h>
|
||||
#include <util/goodies.h>
|
||||
#include <util/language.h>
|
||||
#include <util/log.h>
|
||||
|
@ -84,17 +85,17 @@ static void unitmessage_write(const trigger * t, struct storage *store)
|
|||
WRITE_INT(store, td->level);
|
||||
}
|
||||
|
||||
static int unitmessage_read(trigger * t, struct storage *store)
|
||||
static int unitmessage_read(trigger * t, gamedata *data)
|
||||
{
|
||||
unitmessage_data *td = (unitmessage_data *)t->data.v;
|
||||
char zText[256];
|
||||
|
||||
int result =
|
||||
read_reference(&td->target, store, read_unit_reference, resolve_unit);
|
||||
READ_TOK(store, zText, sizeof(zText));
|
||||
read_reference(&td->target, data->store, read_unit_reference, resolve_unit);
|
||||
READ_TOK(data->store, zText, sizeof(zText));
|
||||
td->string = _strdup(zText);
|
||||
READ_INT(store, &td->type);
|
||||
READ_INT(store, &td->level);
|
||||
READ_INT(data->store, &td->type);
|
||||
READ_INT(data->store, &td->level);
|
||||
|
||||
if (result == 0 && td->target == NULL) {
|
||||
return AT_READ_FAIL;
|
||||
|
|
|
@ -43,20 +43,20 @@ void write_triggers(struct storage *store, const trigger * t)
|
|||
WRITE_TOK(store, "end");
|
||||
}
|
||||
|
||||
int read_triggers(struct storage *store, trigger ** tp)
|
||||
int read_triggers(struct gamedata *data, trigger ** tp)
|
||||
{
|
||||
for (;;) {
|
||||
trigger_type *ttype;
|
||||
char zText[128];
|
||||
|
||||
READ_TOK(store, zText, sizeof(zText));
|
||||
READ_TOK(data->store, zText, sizeof(zText));
|
||||
if (!strcmp(zText, "end"))
|
||||
break;
|
||||
ttype = tt_find(zText);
|
||||
assert(ttype || !"unknown trigger-type");
|
||||
*tp = t_new(ttype);
|
||||
if (ttype->read) {
|
||||
int i = ttype->read(*tp, store);
|
||||
int i = ttype->read(*tp, data);
|
||||
switch (i) {
|
||||
case AT_READ_OK:
|
||||
tp = &(*tp)->next;
|
||||
|
@ -152,7 +152,7 @@ static int read_handler(attrib * a, void *owner, gamedata *data)
|
|||
|
||||
READ_TOK(store, zText, sizeof(zText));
|
||||
hi->event = _strdup(zText);
|
||||
read_triggers(store, &hi->triggers);
|
||||
read_triggers(data, &hi->triggers);
|
||||
if (hi->triggers != NULL) {
|
||||
return AT_READ_OK;
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ extern "C" {
|
|||
struct attrib;
|
||||
struct trigger;
|
||||
struct storage;
|
||||
struct gamedata;
|
||||
|
||||
typedef struct trigger_type {
|
||||
const char *name;
|
||||
|
@ -34,7 +35,7 @@ extern "C" {
|
|||
void(*finalize) (struct trigger *);
|
||||
int(*handle) (struct trigger *, void *);
|
||||
void(*write) (const struct trigger *, struct storage * store);
|
||||
int(*read) (struct trigger *, struct storage * store);
|
||||
int(*read) (struct trigger *, struct gamedata * store);
|
||||
|
||||
struct trigger_type *next;
|
||||
} trigger_type;
|
||||
|
@ -73,7 +74,7 @@ extern "C" {
|
|||
/* functions for making complex triggers: */
|
||||
void free_triggers(trigger * triggers); /* release all these triggers */
|
||||
void write_triggers(struct storage *store, const trigger * t);
|
||||
int read_triggers(struct storage *store, trigger ** tp);
|
||||
int read_triggers(struct gamedata *data, trigger ** tp);
|
||||
int handle_triggers(trigger ** triggers, void *data);
|
||||
|
||||
extern struct attrib_type at_eventhandler;
|
||||
|
|
Loading…
Reference in New Issue