forked from github/server
builing_action kann jetzt einen string-parameter haben.
This commit is contained in:
parent
293c12c382
commit
032466e908
|
@ -40,6 +40,8 @@
|
||||||
/* attributes includes */
|
/* attributes includes */
|
||||||
#include <attributes/matmod.h>
|
#include <attributes/matmod.h>
|
||||||
|
|
||||||
|
static const char * NULLSTRING = "(null)";
|
||||||
|
|
||||||
static void
|
static void
|
||||||
lc_init(struct attrib *a)
|
lc_init(struct attrib *a)
|
||||||
{
|
{
|
||||||
|
@ -51,6 +53,7 @@ lc_done(struct attrib *a)
|
||||||
{
|
{
|
||||||
building_action * data = (building_action*)a->data.v;
|
building_action * data = (building_action*)a->data.v;
|
||||||
if (data->fname) free(data->fname);
|
if (data->fname) free(data->fname);
|
||||||
|
if (data->param) free(data->param);
|
||||||
free(data);
|
free(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,10 +62,14 @@ lc_write(const struct attrib * a, FILE* F)
|
||||||
{
|
{
|
||||||
building_action * data = (building_action*)a->data.v;
|
building_action * data = (building_action*)a->data.v;
|
||||||
const char * fname = data->fname;
|
const char * fname = data->fname;
|
||||||
|
const char * fparam = data->param;
|
||||||
building * b = data->b;
|
building * b = data->b;
|
||||||
|
|
||||||
write_building_reference(b, F);
|
write_building_reference(b, F);
|
||||||
fwritestr(F, fname);
|
fwritestr(F, fname);
|
||||||
|
#if RELEASE_VERSION>=BACTION_VERSION
|
||||||
|
fwritestr(F, fparam?fparam:NULLSTRING);
|
||||||
|
#endif
|
||||||
fputc(' ', F);
|
fputc(' ', F);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,6 +82,13 @@ lc_read(struct attrib * a, FILE* F)
|
||||||
read_building_reference(&data->b, F);
|
read_building_reference(&data->b, F);
|
||||||
freadstr(F, lbuf, sizeof(lbuf));
|
freadstr(F, lbuf, sizeof(lbuf));
|
||||||
data->fname = strdup(lbuf);
|
data->fname = strdup(lbuf);
|
||||||
|
if (global.data_version>=BACTION_VERSION) {
|
||||||
|
freadstr(F, lbuf, sizeof(lbuf));
|
||||||
|
if (strcmp(lbuf, NULLSTRING)==0) data->param = NULL;
|
||||||
|
else data->param = strdup(lbuf);
|
||||||
|
} else {
|
||||||
|
data->param = strdup(NULLSTRING);
|
||||||
|
}
|
||||||
return AT_READ_OK;
|
return AT_READ_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -145,6 +145,7 @@ extern attrib_type at_building_action;
|
||||||
typedef struct building_action {
|
typedef struct building_action {
|
||||||
building * b;
|
building * b;
|
||||||
char * fname;
|
char * fname;
|
||||||
|
char * param;
|
||||||
} building_action;
|
} building_action;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -161,6 +161,7 @@ struct building_type;
|
||||||
#define SAVEXMLNAME_VERSION 316
|
#define SAVEXMLNAME_VERSION 316
|
||||||
#define SAVEALLIANCE_VERSION 317
|
#define SAVEALLIANCE_VERSION 317
|
||||||
#define CLAIM_VERSION 318
|
#define CLAIM_VERSION 318
|
||||||
|
#define BACTION_VERSION 319 /* building action gets a param string */
|
||||||
|
|
||||||
#define MIN_VERSION ALLIANCES_VERSION
|
#define MIN_VERSION ALLIANCES_VERSION
|
||||||
#define REGIONOWNERS_VERSION 400
|
#define REGIONOWNERS_VERSION 400
|
||||||
|
@ -169,7 +170,7 @@ struct building_type;
|
||||||
#ifdef REGIONOWNERS
|
#ifdef REGIONOWNERS
|
||||||
# define RELEASE_VERSION REGIONOWNERS_VERSION
|
# define RELEASE_VERSION REGIONOWNERS_VERSION
|
||||||
#else
|
#else
|
||||||
# define RELEASE_VERSION CLAIM_VERSION
|
# define RELEASE_VERSION BACTION_VERSION
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if RESOURCE_CONVERSION
|
#if RESOURCE_CONVERSION
|
||||||
|
|
|
@ -36,6 +36,7 @@ lc_age(struct attrib * a)
|
||||||
lua_State * L = (lua_State *)global.vm_state;
|
lua_State * L = (lua_State *)global.vm_state;
|
||||||
building_action * data = (building_action*)a->data.v;
|
building_action * data = (building_action*)a->data.v;
|
||||||
const char * fname = data->fname;
|
const char * fname = data->fname;
|
||||||
|
const char * fparam = data->param;
|
||||||
building * b = data->b;
|
building * b = data->b;
|
||||||
|
|
||||||
assert(b!=NULL);
|
assert(b!=NULL);
|
||||||
|
@ -62,16 +63,21 @@ lc_age(struct attrib * a)
|
||||||
std::terminate();
|
std::terminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
return luabind::call_function<int>(L, fname, *b);
|
if (fparam) {
|
||||||
|
return luabind::call_function<int>(L, fname, *b, fparam);
|
||||||
|
} else {
|
||||||
|
return luabind::call_function<int>(L, fname, *b);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
building_addaction(building& b, const char * fname)
|
building_addaction(building& b, const char * fname, const char * param)
|
||||||
{
|
{
|
||||||
attrib * a = a_add(&b.attribs, a_new(&at_building_action));
|
attrib * a = a_add(&b.attribs, a_new(&at_building_action));
|
||||||
building_action * data = (building_action*)a->data.v;
|
building_action * data = (building_action*)a->data.v;
|
||||||
data->b = &b;
|
data->b = &b;
|
||||||
data->fname = strdup(fname);
|
data->fname = strdup(fname);
|
||||||
|
if (param) data->param = strdup(param);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,7 +171,6 @@ region_remove(region& r)
|
||||||
region ** rp = ®ions;
|
region ** rp = ®ions;
|
||||||
while (*rp) {
|
while (*rp) {
|
||||||
if (*rp==&r) {
|
if (*rp==&r) {
|
||||||
unit * u;
|
|
||||||
while (r.units) {
|
while (r.units) {
|
||||||
destroy_unit(r.units);
|
destroy_unit(r.units);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue