forked from github/server
Startbedingungen können per Skript gesetzt werden.
Kompletter benötigter Skript-Support für WdW-Aussetzung fertig und getestet.
This commit is contained in:
parent
99bc41219b
commit
1a8e1acf74
|
@ -2353,7 +2353,7 @@ faction_id_is_unused(int id)
|
|||
return (boolean)(bsearch(&id, used_faction_ids, no_used_faction_ids,
|
||||
sizeof(int), _cmp_int) == NULL);
|
||||
#else
|
||||
return true;
|
||||
return findfaction(id)==NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -193,15 +193,32 @@ set_show_item(faction *f, item_t i)
|
|||
a->data.v = (void*)olditemtype[i];
|
||||
}
|
||||
|
||||
#ifdef NEW_STARTEQUIPMENT
|
||||
static item * equipment;
|
||||
void add_equipment(const item_type * itype, int number)
|
||||
{
|
||||
if (itype!=NULL) i_change(&equipment, itype, number);
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
give_starting_equipment(struct region *r, struct unit *u)
|
||||
{
|
||||
#ifdef NEW_STARTEQUIPMENT
|
||||
item * itm = equipment;
|
||||
while (itm!=NULL) {
|
||||
i_add(&u->items, i_new(itm->type, itm->number));
|
||||
itm=itm->next;
|
||||
}
|
||||
#else
|
||||
const item_type * token = it_find("conquesttoken");
|
||||
if (token!=NULL) {
|
||||
i_add(&u->items, i_new(token, 1));
|
||||
}
|
||||
set_item(u, I_WOOD, 30);
|
||||
set_item(u, I_STONE, 30);
|
||||
set_money(u, 2000 + turn * 10);
|
||||
#endif
|
||||
|
||||
switch(old_race(u->race)) {
|
||||
case RC_DWARF:
|
||||
|
@ -278,8 +295,6 @@ give_starting_equipment(struct region *r, struct unit *u)
|
|||
rsethorses(r, 250+rand()%51+rand()%51);
|
||||
break;
|
||||
}
|
||||
|
||||
set_money(u, 2000 + turn * 10);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
@ -143,7 +143,6 @@ extern int rc_specialdamage(const race *, const race *, const struct weapon_type
|
|||
#define BF_RES_BASH (1<<4) /* Halber Schaden durch BASH */
|
||||
#define BF_INV_NONMAGIC (1<<5) /* Immun gegen nichtmagischen Schaden */
|
||||
|
||||
extern void give_starting_equipment(struct region *r, struct unit *u);
|
||||
extern int unit_old_max_hp(struct unit * u);
|
||||
extern const char * racename(const struct locale *lang, const struct unit *u, const race * rc);
|
||||
|
||||
|
@ -168,6 +167,11 @@ extern int read_race_reference(const struct race ** rp, FILE * F);
|
|||
|
||||
extern const char * raceprefix(const struct unit *u);
|
||||
|
||||
#ifdef NEW_STARTEQUIPMENT
|
||||
extern void add_equipment(const struct item_type * itype, int number);
|
||||
#endif
|
||||
extern void give_starting_equipment(struct region *r, struct unit *u);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -846,7 +846,7 @@ read_alliances(FILE * F)
|
|||
#endif
|
||||
|
||||
int
|
||||
readgame(boolean backup)
|
||||
readgame(const char * filename, boolean backup)
|
||||
{
|
||||
int i, n, p;
|
||||
faction *f, **fp;
|
||||
|
@ -857,7 +857,7 @@ readgame(boolean backup)
|
|||
FILE * F;
|
||||
int rmax = maxregions;
|
||||
|
||||
sprintf(buf, "%s/%d", datapath(), turn);
|
||||
sprintf(buf, "%s/%s", datapath(), filename);
|
||||
if (backup) create_backup(buf);
|
||||
F = cfopen(buf, "r");
|
||||
if (F==NULL) {
|
||||
|
@ -1304,7 +1304,7 @@ export_players(const char * path)
|
|||
#endif
|
||||
|
||||
void
|
||||
writegame(char *path, char quiet)
|
||||
writegame(const char *filename, char quiet)
|
||||
{
|
||||
int i,n;
|
||||
faction *f;
|
||||
|
@ -1325,7 +1325,8 @@ writegame(char *path, char quiet)
|
|||
|
||||
/* write_dynamictypes(); */
|
||||
|
||||
F = cfopen(path, "w");
|
||||
sprintf(buf, "%s/%s", datapath(), filename);
|
||||
F = cfopen(buf, "w");
|
||||
if (F==NULL)
|
||||
return;
|
||||
|
||||
|
|
|
@ -36,8 +36,8 @@ double version(void);
|
|||
FILE * cfopen(const char *filename, const char *mode);
|
||||
int readorders(const char *);
|
||||
int creategame(void);
|
||||
int readgame(boolean backup);
|
||||
void writegame(char *path, char quiet);
|
||||
extern int readgame(const char * filename, boolean backup);
|
||||
void writegame(const char *filename, char quiet);
|
||||
|
||||
extern void rsf(FILE * F, char *s, size_t len);
|
||||
|
||||
|
|
|
@ -49,5 +49,6 @@
|
|||
#define AUTOALLIANCE (HELP_FIGHT)
|
||||
|
||||
#define WDW_PHOENIX
|
||||
#define NEW_STARTEQUIPMENT
|
||||
|
||||
#define MAILITPATH "/usr/sbin:$HOME/bin:/bin:/usr/bin:/usr/local/bin"
|
||||
|
|
|
@ -1,16 +1,27 @@
|
|||
function process(orders)
|
||||
if read_game()~=0 then
|
||||
file = "" .. get_turn()
|
||||
if read_game(file)~=0 then
|
||||
print("could not read game")
|
||||
return -1
|
||||
end
|
||||
|
||||
-- initialize starting equipment for new players
|
||||
-- probably not necessary, since mapper sets new players, not server
|
||||
add_equipment("conquesttoken", 1);
|
||||
add_equipment("wood", 30);
|
||||
add_equipment("stone", 30);
|
||||
add_equipment("money", 2000 + get_turn() * 10);
|
||||
|
||||
read_orders(orders)
|
||||
process_orders()
|
||||
|
||||
write_passwords()
|
||||
write_reports()
|
||||
|
||||
if write_game()~=0 then
|
||||
print(turn .. " " .. get_turn())
|
||||
|
||||
file = "" .. get_turn()
|
||||
if write_game(file)~=0 then
|
||||
print("could not write game")
|
||||
return -1
|
||||
end
|
||||
|
|
|
@ -4,9 +4,11 @@
|
|||
|
||||
// kernel includes
|
||||
#include <gamecode/laws.h>
|
||||
#include <kernel/race.h>
|
||||
#include <kernel/item.h>
|
||||
#include <kernel/reports.h>
|
||||
#include <kernel/save.h>
|
||||
#include <kernel/unit.h>
|
||||
#include <kernel/reports.h>
|
||||
#include <util/language.h>
|
||||
|
||||
// lua includes
|
||||
|
@ -16,6 +18,15 @@
|
|||
|
||||
using namespace luabind;
|
||||
|
||||
static int
|
||||
lua_addequipment(const char * iname, int number)
|
||||
{
|
||||
const struct item_type * itype = it_find(iname);
|
||||
if (itype==NULL) return -1;
|
||||
add_equipment(itype, number);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
get_turn(void)
|
||||
{
|
||||
|
@ -23,21 +34,20 @@ get_turn(void)
|
|||
}
|
||||
|
||||
static int
|
||||
read_game(void)
|
||||
read_game(const char * filename)
|
||||
{
|
||||
return readgame(false);
|
||||
return readgame(filename, false);
|
||||
}
|
||||
|
||||
static int
|
||||
write_game(void)
|
||||
write_game(const char *filename)
|
||||
{
|
||||
char ztext[64];
|
||||
|
||||
free_units();
|
||||
remove_empty_factions(true);
|
||||
|
||||
sprintf(ztext, "%s/%d", datapath(), turn);
|
||||
writegame(ztext, 0);
|
||||
writegame(filename, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -62,6 +72,7 @@ bind_eressea(lua_State * L)
|
|||
def("write_reports", &write_reports),
|
||||
def("read_orders", &readorders),
|
||||
def("process_orders", &process_orders),
|
||||
def("add_equipment", &lua_addequipment),
|
||||
def("get_turn", &get_turn)
|
||||
];
|
||||
}
|
||||
|
|
|
@ -15,11 +15,14 @@
|
|||
using namespace luabind;
|
||||
|
||||
static faction *
|
||||
add_faction(const char * email, const char * passwd, const char * racename, const char * lang)
|
||||
add_faction(const char * email, const char * racename, const char * lang)
|
||||
{
|
||||
const race * frace = findrace(racename, default_locale);
|
||||
if (frace==NULL) frace = findrace(racename, find_locale("de"));
|
||||
if (frace==NULL) frace = findrace(racename, find_locale("en"));
|
||||
if (frace==NULL) return NULL;
|
||||
locale * loc = find_locale(lang);
|
||||
faction * f = addfaction(email, passwd, frace, loc, 0);
|
||||
faction * f = addfaction(email, NULL, frace, loc, 0);
|
||||
return f;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,6 +40,11 @@ region_setname(region& r, const char * name) {
|
|||
if (r.land) rsetname((&r), name);
|
||||
}
|
||||
|
||||
static const char *
|
||||
region_getterrain(const region& r) {
|
||||
return terrain[r.terrain].name;
|
||||
}
|
||||
|
||||
static const char *
|
||||
region_getname(const region& r) {
|
||||
if (r.land) return r.land->name;
|
||||
|
@ -66,6 +71,7 @@ bind_region(lua_State * L)
|
|||
class_<struct region>("region")
|
||||
.property("name", ®ion_getname, ®ion_setname)
|
||||
.property("info", ®ion_getinfo, ®ion_setinfo)
|
||||
.property("terrain", ®ion_getterrain)
|
||||
.def_readonly("x", ®ion::x)
|
||||
.def_readonly("y", ®ion::y)
|
||||
.def_readwrite("age", ®ion::age)
|
||||
|
|
|
@ -25,7 +25,10 @@ add_unit(faction * f, region * r)
|
|||
static void
|
||||
unit_setnumber(unit& u, int number)
|
||||
{
|
||||
if (u.number==0) set_number(&u, number);
|
||||
if (u.number==0) {
|
||||
set_number(&u, number);
|
||||
u.hp = unit_max_hp(&u) * number;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
|
@ -706,7 +706,16 @@ main(int argc, char *argv[])
|
|||
return 0;
|
||||
#endif
|
||||
|
||||
|
||||
if ((i=readgame(false))!=0) return i;
|
||||
|
||||
#ifdef NEW_STARTEQUIPMENT
|
||||
add_equipment(it_find("conquesttoken"), 1);
|
||||
add_equipment(it_find("wood"), 30);
|
||||
add_equipment(it_find("stone"), 30);
|
||||
add_equipment(it_find("money"), 2000 + turn * 10);
|
||||
#endif
|
||||
|
||||
confirm_newbies();
|
||||
update_subscriptions();
|
||||
{
|
||||
|
|
|
@ -336,6 +336,40 @@ lua_done(lua_State * luaState)
|
|||
lua_close(luaState);
|
||||
}
|
||||
|
||||
static void
|
||||
update_subscriptions(void)
|
||||
{
|
||||
FILE * F;
|
||||
char zText[MAX_PATH];
|
||||
faction * f;
|
||||
strcat(strcpy(zText, basepath()), "/subscriptions");
|
||||
F = fopen(zText, "r");
|
||||
if (F==NULL) {
|
||||
log_error(("could not open %s.\n", zText));
|
||||
return;
|
||||
}
|
||||
for (;;) {
|
||||
char zFaction[5];
|
||||
int subscription, fno;
|
||||
if (fscanf(F, "%d %s", &subscription, zFaction)<=0) break;
|
||||
fno = atoi36(zFaction);
|
||||
f = findfaction(fno);
|
||||
if (f!=NULL) {
|
||||
f->subscription=subscription;
|
||||
}
|
||||
}
|
||||
fclose(F);
|
||||
|
||||
sprintf(zText, "subscriptions.%u", turn);
|
||||
F = fopen(zText, "w");
|
||||
for (f=factions;f!=NULL;f=f->next) {
|
||||
fprintf(F, "%s:%u:%s:%s:%s:%u:\n",
|
||||
itoa36(f->no), f->subscription, f->email, f->override,
|
||||
dbrace(f->race), f->lastorders);
|
||||
}
|
||||
fclose(F);
|
||||
}
|
||||
|
||||
int
|
||||
process_orders()
|
||||
{
|
||||
|
@ -678,40 +712,6 @@ typedef struct lostdata {
|
|||
int ship;
|
||||
} lostdata;
|
||||
|
||||
void
|
||||
update_subscriptions(void)
|
||||
{
|
||||
FILE * F;
|
||||
char zText[MAX_PATH];
|
||||
faction * f;
|
||||
strcat(strcpy(zText, basepath()), "/subscriptions");
|
||||
F = fopen(zText, "r");
|
||||
if (F==NULL) {
|
||||
log_error(("could not open %s.\n", zText));
|
||||
return;
|
||||
}
|
||||
for (;;) {
|
||||
char zFaction[5];
|
||||
int subscription, fno;
|
||||
if (fscanf(F, "%d %s", &subscription, zFaction)<=0) break;
|
||||
fno = atoi36(zFaction);
|
||||
f = findfaction(fno);
|
||||
if (f!=NULL) {
|
||||
f->subscription=subscription;
|
||||
}
|
||||
}
|
||||
fclose(F);
|
||||
|
||||
sprintf(zText, "subscriptions.%u", turn);
|
||||
F = fopen(zText, "w");
|
||||
for (f=factions;f!=NULL;f=f->next) {
|
||||
fprintf(F, "%s:%u:%s:%s:%s:%u:\n",
|
||||
itoa36(f->no), f->subscription, f->email, f->override,
|
||||
dbrace(f->race), f->lastorders);
|
||||
}
|
||||
fclose(F);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
|
@ -722,7 +722,7 @@ main(int argc, char *argv[])
|
|||
updatelog = fopen("update.log", "w");
|
||||
log_open("eressea.log");
|
||||
printf("\n%s PBEM host\n"
|
||||
"Copyright (C) 1996-2001 C.Schlittchen, K.Zedel, E.Rehling, H.Peters.\n\n"
|
||||
"Copyright (C) 1996-2003 C. Schlittchen, K. Zedel, E. Rehling, H. Peters.\n\n"
|
||||
"Compilation: " __DATE__ " at " __TIME__ "\nVersion: %f\n\n", global.gamename, version());
|
||||
|
||||
setlocale(LC_ALL, "");
|
||||
|
|
|
@ -1702,10 +1702,9 @@ main(int argc, char *argv[])
|
|||
|
||||
init_gmcmd();
|
||||
|
||||
if(!*datafile)
|
||||
sprintf(datafile, "%s/%d", datapath(), turn);
|
||||
if (!*datafile) ssprintf(datafile, "%u", turn);
|
||||
|
||||
readgame(backup);
|
||||
readgame(datafile, backup);
|
||||
for (f=factions;f;f=f->next) if (f->age==0) {
|
||||
++numnewbies;
|
||||
}
|
||||
|
|
|
@ -71,7 +71,6 @@ void NeuePartei(struct region * r);
|
|||
void RemovePartei(void);
|
||||
int ParteiListe(void);
|
||||
int koor_distance(int a, int b, int x, int y);
|
||||
int readgame(boolean backup);
|
||||
int create_backup(char *file);
|
||||
void SpecialFunction(struct region *r);
|
||||
|
||||
|
|
Loading…
Reference in New Issue