Farbiger mapper, monsterpartei, segfault

This commit is contained in:
Enno Rehling 2001-12-16 09:57:46 +00:00
parent fe9ef7457e
commit 6963a11ce7
4 changed files with 49 additions and 6 deletions

View File

@ -1251,6 +1251,28 @@ extern int fuzzy_hits;
boolean enable_fuzzy = false; boolean enable_fuzzy = false;
#endif /* FUZZY_BASE36 */ #endif /* FUZZY_BASE36 */
static faction *
makemonsters(void)
{
faction * f = calloc(sizeof(faction), 1);
f->next=factions;
f->race=new_race[RC_TEMPLATE];
f->alive=1;
f->email=strdup("");
f->lastorders=0;
f->locale=default_locale;
factions=f;
f->options = Pow(O_REPORT);
f->no=MONSTER_FACTION;
register_faction_id(f->no);
f->unique_id = ++max_unique_id;
f->name=strdup("Monster");
f->passw=strdup("abc123");
fhash(f);
return f;
}
faction * faction *
findfaction (int n) findfaction (int n)
{ {
@ -1278,7 +1300,7 @@ findfaction (int n)
} }
} }
#endif /* FUZZY_BASE36 */ #endif /* FUZZY_BASE36 */
if (n==MONSTER_FACTION) return makemonsters();
return NULL; return NULL;
} }

View File

@ -690,7 +690,7 @@ new_region(int x, int y)
region *r = rfindhash(x, y); region *r = rfindhash(x, y);
if (r) { if (r) {
fprintf(stderr, "\ndoppelte regionen entdeckt: %s\n", regionname(r, NULL)); fprintf(stderr, "\ndoppelte regionen entdeckt: %s(%d,%d)\n", regionname(r, NULL), x, y);
if (r->units) if (r->units)
fprintf(stderr, "doppelte region enthält einheiten\n"); fprintf(stderr, "doppelte region enthält einheiten\n");
return r; return r;

View File

@ -2651,7 +2651,7 @@ dump_sql(void)
if (f->unique_id==0) { if (f->unique_id==0) {
f->unique_id = ++max_unique_id; f->unique_id = ++max_unique_id;
} }
if (f->age!=1) { if (f->age!=1 && f->no!=MONSTER_FACTION) {
fprintf(sqlstream, "INSERT INTO users (id, email) VALUES (%d, '%s');\n", fprintf(sqlstream, "INSERT INTO users (id, email) VALUES (%d, '%s');\n",
f->unique_id, f->email); f->unique_id, f->email);
fprintf(sqlstream, "INSERT INTO factions (id, user, name, password, race, locale, lastorders, banner, email) " fprintf(sqlstream, "INSERT INTO factions (id, user, name, password, race, locale, lastorders, banner, email) "

View File

@ -158,8 +158,25 @@ init_win(int x, int y) {
static int hl; static int hl;
int politkarte = 0; int politkarte = 0;
int
RegionColor(const region *r) {
static int usecolor=0;
if (!usecolor) {
start_color();
init_pair(T_PLAIN, COLOR_GREEN, COLOR_BLACK);
init_pair(T_SWAMP, COLOR_RED, COLOR_BLACK);
init_pair(T_OCEAN, COLOR_BLUE, COLOR_BLACK);
init_pair(T_GLACIER, COLOR_WHITE, COLOR_BLACK);
init_pair(T_HIGHLAND, COLOR_YELLOW, COLOR_BLACK);
init_pair(T_DESERT, COLOR_CYAN, COLOR_BLACK);
init_pair(T_MOUNTAIN, COLOR_WHITE, COLOR_BLACK);
usecolor=1;
}
return COLOR_PAIR(rterrain(r));
}
chtype chtype
RegionSymbol(region *r) { RegionSymbol(const region *r) {
chtype rs; chtype rs;
int p; int p;
@ -300,7 +317,7 @@ static void
readfactions(void) readfactions(void)
{ {
FILE * F = fopen("factions.txt", "r"); FILE * F = fopen("factions.txt", "r");
region * r;
locale * german = find_locale("de"); locale * german = find_locale("de");
while (!feof(F)) { while (!feof(F)) {
int x, y; int x, y;
@ -405,6 +422,7 @@ drawmap(boolean maponly) {
addch(' '); addch(' ');
if (r) { if (r) {
int rc = RegionColor(r);
if ((hl == -2 && r->units) || if ((hl == -2 && r->units) ||
(hl == -3 && r->buildings) || (hl == -3 && r->buildings) ||
(hl == -4 && r->ships) || (hl == -4 && r->ships) ||
@ -417,8 +435,11 @@ drawmap(boolean maponly) {
addch(rs | A_REVERSE); addch(rs | A_REVERSE);
else if (is_tagged(r)) else if (is_tagged(r))
addch(rs | A_BOLD); addch(rs | A_BOLD);
else else {
attrset(rc | A_NORMAL);
addch(rs); addch(rs);
attrset(A_NORMAL);
}
} else } else
addch(rs); addch(rs);
} }