forked from github/server
- maxsize für einheiten
- fehler bei u_setfaction-änderung - faction specials? was für faction specials... - signal handler für SIGSEGV, backtraces
This commit is contained in:
parent
3eea6880a8
commit
b445cc1ed3
8 changed files with 79 additions and 38 deletions
|
@ -1,6 +1,8 @@
|
||||||
C++ = g++ ;
|
C++ = g++ ;
|
||||||
CC = gcc ;
|
CC = gcc ;
|
||||||
|
|
||||||
|
LINKFLAGS += -rdynamic ;
|
||||||
|
|
||||||
if ! $(HAVE_LUA) {
|
if ! $(HAVE_LUA) {
|
||||||
HAVE_LUA = 1 ;
|
HAVE_LUA = 1 ;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2482,9 +2482,6 @@ aftermath(battle * b)
|
||||||
sum_hp += df->person[n].hp;
|
sum_hp += df->person[n].hp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* die weggerannten werden später subtrahiert! */
|
|
||||||
assert(du->number >= 0);
|
|
||||||
|
|
||||||
if (df->alive == du->number) {
|
if (df->alive == du->number) {
|
||||||
du->hp = sum_hp;
|
du->hp = sum_hp;
|
||||||
continue; /* nichts passiert */
|
continue; /* nichts passiert */
|
||||||
|
|
|
@ -734,7 +734,7 @@ verify_data(void)
|
||||||
}
|
}
|
||||||
if (eff_skill(u, SK_ALCHEMY, u->region))
|
if (eff_skill(u, SK_ALCHEMY, u->region))
|
||||||
alchemist += u->number;
|
alchemist += u->number;
|
||||||
if (u->number > 50000 || u->number < 0) {
|
if (u->number > UNIT_MAXSIZE) {
|
||||||
if (lf != f->no) {
|
if (lf != f->no) {
|
||||||
lf = f->no;
|
lf = f->no;
|
||||||
printf("Partei %s:\n", factionid(f));
|
printf("Partei %s:\n", factionid(f));
|
||||||
|
@ -2535,9 +2535,8 @@ remove_empty_units_in_region(region *r)
|
||||||
faction * f = u->faction;
|
faction * f = u->faction;
|
||||||
if (!fval(f, FFL_NOTIMEOUT) && f->age > MaxAge()) set_number(u, 0);
|
if (!fval(f, FFL_NOTIMEOUT) && f->age > MaxAge()) set_number(u, 0);
|
||||||
}
|
}
|
||||||
if ((u->number <= 0 && u->race != new_race[RC_SPELL])
|
if ((u->number == 0 && u->race != new_race[RC_SPELL])
|
||||||
|| (u->age <= 0 && u->race == new_race[RC_SPELL])
|
|| (u->age <= 0 && u->race == new_race[RC_SPELL])) {
|
||||||
|| u->number < 0) {
|
|
||||||
destroy_unit(u);
|
destroy_unit(u);
|
||||||
}
|
}
|
||||||
if (*up==u) up=&u->next;
|
if (*up==u) up=&u->next;
|
||||||
|
|
|
@ -351,13 +351,14 @@ buy_special(unit *u, struct order * ord, fspecial_t special)
|
||||||
int
|
int
|
||||||
fspecial(const faction *f, fspecial_t special)
|
fspecial(const faction *f, fspecial_t special)
|
||||||
{
|
{
|
||||||
attrib *a;
|
#ifdef KARMA_MODULE
|
||||||
|
attrib *a;
|
||||||
|
|
||||||
for(a=a_find(f->attribs, &at_faction_special); a; a=a->nexttype) {
|
for(a=a_find(f->attribs, &at_faction_special); a; a=a->nexttype) {
|
||||||
if(a->data.sa[0] == special) return a->data.sa[1];
|
if(a->data.sa[0] == special) return a->data.sa[1];
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
|
@ -1124,7 +1124,7 @@ readunit(FILE * F)
|
||||||
}
|
}
|
||||||
set_order(&u->thisorder, NULL);
|
set_order(&u->thisorder, NULL);
|
||||||
|
|
||||||
assert(u->number >= 0);
|
assert(u->number <= UNIT_MAXSIZE);
|
||||||
assert(u->race);
|
assert(u->race);
|
||||||
if (global.data_version<NEWSKILL_VERSION) {
|
if (global.data_version<NEWSKILL_VERSION) {
|
||||||
/* convert old data */
|
/* convert old data */
|
||||||
|
@ -1236,7 +1236,7 @@ writeunit(FILE * F, const unit * u)
|
||||||
wnl(F);
|
wnl(F);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
assert(u->number >= 0);
|
assert(u->number <= UNIT_MAXSIZE);
|
||||||
assert(u->race);
|
assert(u->race);
|
||||||
|
|
||||||
for (i=0;i!=u->skill_size;++i) {
|
for (i=0;i!=u->skill_size;++i) {
|
||||||
|
|
|
@ -807,9 +807,9 @@ inside_building(const struct unit * u)
|
||||||
void
|
void
|
||||||
u_setfaction(unit * u, faction * f)
|
u_setfaction(unit * u, faction * f)
|
||||||
{
|
{
|
||||||
int cnt = u->number;
|
int cnt = u->number;
|
||||||
unit ** iunit;
|
unit ** iunit;
|
||||||
if (u->faction==f) return;
|
if (u->faction==f) return;
|
||||||
if (u->faction) {
|
if (u->faction) {
|
||||||
set_number(u, 0);
|
set_number(u, 0);
|
||||||
if (playerrace(u->race)) {
|
if (playerrace(u->race)) {
|
||||||
|
@ -823,17 +823,20 @@ u_setfaction(unit * u, faction * f)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
iunit = &f->units;
|
if (u->faction!=NULL) {
|
||||||
while (*iunit!=u) iunit=&(*iunit)->next;
|
iunit = &u->faction->units;
|
||||||
assert(*iunit);
|
while (*iunit && *iunit!=u) {
|
||||||
|
iunit=&(*iunit)->nextF;
|
||||||
|
}
|
||||||
|
assert(*iunit);
|
||||||
|
*iunit = u->nextF;
|
||||||
|
}
|
||||||
|
|
||||||
*iunit = u->nextF;
|
if (f!=NULL) {
|
||||||
|
u->nextF = f->units;
|
||||||
if (f!=NULL) {
|
f->units = u;
|
||||||
u->nextF = f->units;
|
}
|
||||||
f->units = u;
|
else u->nextF = NULL;
|
||||||
}
|
|
||||||
else u->nextF = NULL;
|
|
||||||
|
|
||||||
u->faction = f;
|
u->faction = f;
|
||||||
if (u->region) update_interval(f, u->region);
|
if (u->region) update_interval(f, u->region);
|
||||||
|
@ -844,27 +847,28 @@ u_setfaction(unit * u, faction * f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* vorsicht Sprüche können u->number == 0 (RS_FARVISION) haben! */
|
/* vorsicht Sprüche können u->number == 0 (RS_FARVISION) haben! */
|
||||||
void
|
void
|
||||||
set_number(unit * u, int count)
|
set_number(unit * u, int count)
|
||||||
{
|
{
|
||||||
assert (count >= 0);
|
assert (count >= 0);
|
||||||
assert (count <= SHRT_MAX);
|
assert (count <= USHRT_MAX);
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
assert (u->faction != 0 || u->number > 0);
|
assert (u->faction != 0 || u->number > 0);
|
||||||
#endif
|
#endif
|
||||||
if (u->faction && u->race != u->faction->race && playerrace(u->race)
|
if (u->faction && u->race != u->faction->race && playerrace(u->race)
|
||||||
&& old_race(u->race) != RC_SPELL && old_race(u->race) != RC_SPECIAL
|
&& old_race(u->race) != RC_SPELL && old_race(u->race) != RC_SPECIAL
|
||||||
&& !(is_cursed(u->attribs, C_SLAVE, 0)))
|
&& !(is_cursed(u->attribs, C_SLAVE, 0)))
|
||||||
{
|
{
|
||||||
u->faction->num_migrants += count - u->number;
|
u->faction->num_migrants += count - u->number;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (playerrace(u->race)) {
|
if (playerrace(u->race)) {
|
||||||
u->faction->num_people += count - u->number;
|
u->faction->num_people += count - u->number;
|
||||||
}
|
}
|
||||||
u->number = (short)count;
|
u->number = (unsigned short)count;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean
|
boolean
|
||||||
|
|
|
@ -60,6 +60,7 @@ struct skill;
|
||||||
# define UFL_SAVEMASK (UFL_MOVED | UFL_NOAID | UFL_OWNER | UFL_PARTEITARNUNG | UFL_LOCKED | UFL_HUNGER | FFL_NOIDLEOUT | UFL_TAKEALL | UFL_HERO)
|
# define UFL_SAVEMASK (UFL_MOVED | UFL_NOAID | UFL_OWNER | UFL_PARTEITARNUNG | UFL_LOCKED | UFL_HUNGER | FFL_NOIDLEOUT | UFL_TAKEALL | UFL_HERO)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define UNIT_MAXSIZE 50000
|
||||||
#ifdef HEROES
|
#ifdef HEROES
|
||||||
extern int maxheroes(const struct faction * f);
|
extern int maxheroes(const struct faction * f);
|
||||||
extern int countheroes(const struct faction * f);
|
extern int countheroes(const struct faction * f);
|
||||||
|
@ -78,7 +79,7 @@ typedef struct unit {
|
||||||
struct building *building;
|
struct building *building;
|
||||||
struct ship *ship;
|
struct ship *ship;
|
||||||
short age;
|
short age;
|
||||||
short number;
|
unsigned short number;
|
||||||
|
|
||||||
/* skill data */
|
/* skill data */
|
||||||
short skill_size;
|
short skill_size;
|
||||||
|
|
|
@ -153,6 +153,41 @@ struct settings global = {
|
||||||
1000, /* maxunits */
|
1000, /* maxunits */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef __GNUC__
|
||||||
|
#include <execinfo.h>
|
||||||
|
#include <signal.h>
|
||||||
|
|
||||||
|
static void
|
||||||
|
report_segfault(int signo, siginfo_t * sinf, void * arg)
|
||||||
|
{
|
||||||
|
void * btrace[50];
|
||||||
|
size_t size;
|
||||||
|
int fd = fileno(stderr);
|
||||||
|
|
||||||
|
fputs("\n\nProgram received SIGSEGV, backtrace follows.\n", stderr);
|
||||||
|
size = backtrace(btrace, 50);
|
||||||
|
backtrace_symbols_fd(btrace, size, fd);
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
setup_signal_handler(void)
|
||||||
|
{
|
||||||
|
struct sigaction act;
|
||||||
|
|
||||||
|
act.sa_flags = SA_ONESHOT | SA_SIGINFO;
|
||||||
|
act.sa_sigaction = report_segfault;
|
||||||
|
sigfillset(&act.sa_mask);
|
||||||
|
return sigaction(SIGSEGV, &act, NULL);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
static int
|
||||||
|
setup_signal_handler(void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void
|
static void
|
||||||
game_init(void)
|
game_init(void)
|
||||||
{
|
{
|
||||||
|
@ -644,6 +679,8 @@ main(int argc, char *argv[])
|
||||||
int i;
|
int i;
|
||||||
char zText[MAX_PATH];
|
char zText[MAX_PATH];
|
||||||
|
|
||||||
|
setup_signal_handler();
|
||||||
|
|
||||||
global.data_version = RELEASE_VERSION;
|
global.data_version = RELEASE_VERSION;
|
||||||
sqlpatch = true;
|
sqlpatch = true;
|
||||||
log_open("eressea.log");
|
log_open("eressea.log");
|
||||||
|
|
Loading…
Reference in a new issue