- compiling in VS2005 on my new PC

- eliminating a couple of warnings
- fixed a crash bug or two in the -x option
- fixed an endless loop in give_item
This commit is contained in:
Enno Rehling 2007-10-11 21:48:31 +00:00
parent 4333113c63
commit f8398db851
8 changed files with 62 additions and 52 deletions

View file

@ -1,7 +1,7 @@
/* vi: set ts=2:
*
*
* Eressea PB(E)M host Copyright (C) 1998-2003
* Eressea PB(E)M host Copyright (C) 1998-2007
* Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.kn-bremen.de)
* Henning Peters (faroul@beyond.kn-bremen.de)
@ -17,22 +17,7 @@
extern "C" {
#endif
/* entweder eine grosse Insel (Chance 2/3) mit 25 bis 34 Felder oder eine
* kleine Insel (Chance 1/3) mit 11 bis 24 Feldern. */
enum {
M_TERRAIN,
M_FACTIONS,
M_UNARMED,
MAXMODES
};
void createmonsters(void);
void addunit(void);
void makeblock(int x1, int y1, char chaos);
void writemap(FILE * F, int mode);
void regionspells(void);
#ifdef __cplusplus
}

View file

@ -679,16 +679,18 @@ give_cmd(unit * u, order * ord)
if (u->items) {
item **itmp=&u->items;
while (*itmp) {
const item_type * itype = (*itmp)->type;
if (fval(itype, ITF_HERB) && (*itmp)->number>0) {
item * itm = *itmp;
const item_type * itype = itm->type;
if (fval(itype, ITF_HERB) && itm->number>0) {
/* give_item ändert im fall,das man alles übergibt, die
* item-liste der unit, darum continue vor pointerumsetzten */
if (give_item((*itmp)->number, (*itmp)->type, u, u2, ord)==0) {
if (give_item(itm->number, itm->type, u, u2, ord)==0) {
given = true;
if (*itmp!=itm) continue;
continue;
}
}
itmp = &(*itmp)->next;
itmp = &itm->next;
}
}
if (!given) cmistake(u, ord, 38, MSG_COMMERCE);
@ -746,7 +748,9 @@ give_cmd(unit * u, order * ord)
const item_type * itype = itm->type;
if (itm->number > 0 && itm->number - get_reservation(u, itype->rtype) > 0) {
n = itm->number - get_reservation(u, itype->rtype);
if (give_item(n, itype, u, u2, ord)==0) continue;
if (give_item(n, itype, u, u2, ord)==0) {
if (*itmp!=itm) continue;
}
}
itmp = &itm->next;
}
@ -1221,11 +1225,11 @@ economics(region *r)
/* RECRUIT orders */
for (u = r->units; u; u = u->next) {
order * ord;
order * ord;
if (!recruit_classic()) {
if (u->number>0) continue;
}
for (ord = u->orders; ord; ord = ord->next) {
for (ord = u->orders; ord; ord = ord->next) {
if (get_keyword(ord) == K_RECRUIT) {
if (recruit_archetypes()) {
if (recruit_archetype(u, ord)>=0) {

View file

@ -3180,7 +3180,7 @@ simplename(region * r)
static char name[17];
const char * cp = rname(r, NULL);
for (i=0;*cp && i!=16;++i, ++cp) {
int c = *cp;
int c = *(unsigned char *)cp;
while (c && !isalpha(c) && !isspace(c)) {
++cp;
c = *(unsigned char*)cp;

View file

@ -95,12 +95,13 @@ get_borders(const region * r1, const region * r2)
border *
new_border(border_type * type, region * from, region * to)
{
border ** bp = get_borders_i(from, to);
border * b = calloc(1, sizeof(struct border));
while (*bp) bp = &(*bp)->next;
*bp = b;
if (from && to) {
border ** bp = get_borders_i(from, to);
while (*bp) bp = &(*bp)->next;
*bp = b;
}
b->type = type;
b->from = from;
b->to = to;
@ -113,26 +114,28 @@ new_border(border_type * type, region * from, region * to)
void
erase_border(border * b)
{
border ** bp = get_borders_i(b->from, b->to);
attrib ** ap = &b->attribs;
while (*ap) a_remove(&b->attribs, *ap);
assert(*bp!=NULL || !"error: border is not registered");
if (*bp==b) {
/* it is the first in the list, so it is in the nexthash list */
if (b->next) {
*bp = b->next;
(*bp)->nexthash = b->nexthash;
if (b->from && b->to) {
border ** bp = get_borders_i(b->from, b->to);
assert(*bp!=NULL || !"error: border is not registered");
if (*bp==b) {
/* it is the first in the list, so it is in the nexthash list */
if (b->next) {
*bp = b->next;
(*bp)->nexthash = b->nexthash;
} else {
*bp = b->nexthash;
}
} else {
*bp = b->nexthash;
while (*bp && *bp != b) {
bp = &(*bp)->next;
}
assert(*bp==b || !"error: border is not registered");
*bp = b->next;
}
} else {
while (*bp && *bp != b) {
bp = &(*bp)->next;
}
assert(*bp==b || !"error: border is not registered");
*bp = b->next;
}
if (b->type->destroy) b->type->destroy(b);
free(b);
@ -542,12 +545,10 @@ read_borders(FILE * f)
}
type = find_bordertype(zText);
if (from) {
if (type==NULL) {
log_error(("[read_borders] unknown border type %s in %s\n", zText,
regionname(from, NULL)));
assert(type || !"border type not registered");
}
if (type==NULL) {
log_error(("[read_borders] unknown border type %s in %s\n", zText,
regionname(from, NULL)));
assert(type || !"border type not registered");
}
if (to==from && type && from) {

View file

@ -1674,9 +1674,19 @@ readgame(const char * filename, int backup)
}
if (skip) {
char * r;
char buffer[128];
#define SKIPSIZE 4096
char buffer[SKIPSIZE];
buffer[SKIPSIZE-1] = '@';
do {
r = fgets(buffer, sizeof(buffer), F); /* skip region */
if (r && buffer[SKIPSIZE-1]!='@') {
while (r && buffer[SKIPSIZE-1]!='@') {
/* our buffer was not big enough */
buffer[SKIPSIZE-1] = '@';
r = fgets(buffer, sizeof(buffer), F);
}
if (r) continue;
}
} while (r && buffer[0]!='\n');
continue;
}

View file

@ -61,7 +61,7 @@ static attrib_type *
at_find(unsigned int hk)
{
const char* translate[3][2] = {
{ "zielregion", "targetregion" }, /* remapping: früher zielregion, heute targetregion */
{ "zielregion", "targetregion" }, /* remapping: from 'zielregion, heute targetregion */
{ "verzaubert", "curse" }, /* remapping: früher verzaubert, jetzt curse */
{ NULL, NULL }
};

View file

@ -27,18 +27,25 @@
# pragma warning(disable: 4056)
/* warning C4056: overflow in floating point constant arithmetic */
# pragma warning(disable: 4201)
/* warning C4201: Nicht dem Standard entsprechende Erweiterung : Struktur/Union ohne Namen */
/* warning C4201: nonstandard extension used : nameless struct/union */
# pragma warning(disable: 4214)
/* warning C4214: Nicht dem Standard entsprechende Erweiterung : Basistyp fuer Bitfeld ist nicht int */
/* warning C4214: nonstandard extension used : bit field types other than int */
# pragma warning(disable: 4100)
/* warning C4100: <name> : unreferenced formal parameter */
# pragma warning(disable: 4996)
/* warning C4100: <name> was declared deprecated */
#ifndef _CRT_SECURE_NO_DEPRECATE
# define _CRT_SECURE_NO_DEPRECATE
#endif
/* http://msdn2.microsoft.com/en-us/library/ms235505(VS.80).aspx */
#ifndef _CRT_DISABLE_PERFCRIT_LOCKS
# define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
#endif /* _MSC_VER_ */
#ifdef __cplusplus
# include <cstdio>

View file

@ -12,12 +12,15 @@
#include <util/message.h>
// lua includes
#pragma warning (push)
#pragma warning (disable: 4127)
#include <lua.hpp>
#include <luabind/luabind.hpp>
#include <luabind/iterator_policy.hpp>
#if LUABIND_BETA >= 7
# include <luabind/operator.hpp>
#endif
#pragma warning (pop)
#include <ostream>