- Etwas cruft entfernt.

- add_order() macht Eressea-Space-Escapen richtig
- log_error fllushed in jedem fall.
- Verweise auf BASE36_VERSION entfernt (ist eh immer b36)
This commit is contained in:
Enno Rehling 2004-06-13 22:16:12 +00:00
parent 5dee77b1b6
commit 9af938319c
10 changed files with 80 additions and 73 deletions

View File

@ -2629,9 +2629,6 @@ reports(void)
#endif
makedir(reportpath(), 0700);
if (global.data_version<BASE36_VERSION) base36conversion();
/* öffnet file BAT (mailit batch file) */
BAT = openbatch();
wants_report = 1 << O_REPORT;

View File

@ -1205,43 +1205,53 @@ count_maxmigrants(const faction * f)
* Aufruf inititialisiert wird? */
const char *
igetstrtoken (const char *s1)
igetstrtoken(const char * initstr)
{
int i;
static const char *s;
static char lbuf[DISPLAYSIZE + 1];
static const unsigned char *s;
static char lbuf[DISPLAYSIZE + 1];
char * cursor = lbuf;
char quotechar = 0;
boolean escape = false;
if (s1) s = s1;
while (*s == ' ')
s++;
i = 0;
if (initstr!=NULL) s = (const unsigned char*)initstr;
while (*s && *s != ' ' && i < DISPLAYSIZE) {
lbuf[i] = (*s);
while (isspace(*s)) ++s;
/* Hier wird space_replacement wieder in space zurueck
* verwandelt, ausser wenn es nach einem escape_char kommt. Im
* letzteren Fall wird escape_char durch space_replacement
* ersetzt, statt den aktuellen char einfach dran zu haengen. */
while (*s && cursor-lbuf < DISPLAYSIZE) {
if (escape) {
*cursor++ = *s++;
} else if (isspace(*s)) {
if (quotechar==0) break;
*cursor++ = *s++;
} else if (*s=='"' || *s=='\'') {
if (*s==quotechar) {
++s;
break;
} else if (quotechar==0) {
quotechar = *s;
++s;
} else {
*cursor++ = *s++;
}
} else if (*s==SPACE_REPLACEMENT) {
*cursor++ = ' ';
++s;
} else if (*s==ESCAPE_CHAR) {
escape = true;
++s;
} else {
*cursor++ = *s++;
}
}
if (*s == SPACE_REPLACEMENT) {
if (i > 0 && lbuf[i - 1] == ESCAPE_CHAR)
lbuf[--i] = SPACE_REPLACEMENT;
else
lbuf[i] = ' ';
}
i++;
s++;
}
lbuf[i] = 0;
return lbuf;
*cursor = '\0';
return lbuf;
}
const char *
getstrtoken (void)
getstrtoken(void)
{
return igetstrtoken (0);
return igetstrtoken (0);
}
int

View File

@ -951,9 +951,8 @@ extern param_t findparam(const char *s, const struct locale * lang);
extern param_t igetparam(const char *s, const struct locale * lang);
extern param_t getparam(const struct locale * lang);
#define BASE36_VERSION 93
extern int atoi36(const char * s);
#define getid() ((global.data_version<BASE36_VERSION)?geti():atoi36(getstrtoken()))
#define getid() atoi36(getstrtoken())
#define getstruct unitid() getid()
#define unitid(x) itoa36((x)->no)

View File

@ -61,10 +61,6 @@ obj_ID default_ID;
/* die müssen schon ein value zurückliefern... */
static char * notimplemented_desc(void *p) { unused(p); assert(0); return 0; }
static void cannot_destroy(void *p) {
fprintf(stderr, "** destroy-method unzerstörbares Objekt <%p> aufgerufen! **\n", p);
}
/****** Unit ******/
static obj_ID unit_ID(void *p) {
obj_ID id; id.a = p ? ((unit *)p)->no : 0; id.b = 0; return id;
@ -75,9 +71,6 @@ static void * unit_find(obj_ID id) {
static attrib ** unit_attribs( void *p ) {
return &((unit *)p)->attribs;
}
static void * unit_deref( void *pp ) {
return (void *) (*((unit **)pp));
}
static void unit_set( void *pp, void *p ) {
*(unit **)pp = (unit *)p;
}
@ -93,9 +86,6 @@ static void * region_find(obj_ID id) {
static attrib ** region_attribs( void *p ) {
return &((region *)p)->attribs;
}
static void * region_deref( void *pp ) {
return (void *) (*((region **)pp));
}
static void region_set( void *pp, void *p ) {
*(region **)pp = (region *)p;
}
@ -110,9 +100,6 @@ static void * building_find(obj_ID id) {
static attrib ** building_attribs( void *p ) {
return &((building *)p)->attribs;
}
static void * building_deref( void *pp ) {
return (void *) (*((building **)pp));
}
static void building_set( void *pp, void *p ) {
*(building **)pp = (building *)p;
}
@ -127,9 +114,6 @@ static obj_ID ship_ID(void *p) {
static attrib ** ship_attribs( void *p ) {
return &((ship *)p)->attribs;
}
static void * ship_deref( void *pp ) {
return (void *) (*((ship **)pp));
}
static void ship_set( void *pp, void *p ) {
*(ship **)pp = (ship *)p;
}
@ -144,9 +128,6 @@ static obj_ID faction_ID(void *p) {
static attrib ** faction_attribs( void *p ) {
return &((faction *)p)->attribs;
}
static void * faction_deref( void *pp ) {
return (void *) (*((faction **)pp));
}
static void faction_set( void *pp, void *p ) {
*(faction **)pp = (faction *)p;
}

View File

@ -134,20 +134,10 @@ cfopen(const char *filename, const char *mode)
/* Dummy-Funktion für die Kompatibilität */
#define rid(F) ((global.data_version<BASE36_VERSION)?ri(F):ri36(F))
#define rid(F) ri36(F)
int nextc;
#ifdef OLD_RC
void
rc(FILE * F)
{
nextc = getc(F);
}
#else
static int nextc;
#define rc(F) (nextc = getc(F))
#endif
#undef CONVERT_DBLINK
#ifdef CONVERT_DBLINK
@ -865,13 +855,14 @@ ws(FILE * F, const char *s)
fputs("\" ", F);
}
void
static void
wi(FILE * F, int n)
{
fprintf(F, "%d ", n);
}
void wi36(FILE * F, int n)
static void
wi36(FILE * F, int n)
{
fprintf(F, "%s ", itoa36(n));
}
@ -897,8 +888,7 @@ write_items(FILE *F, item *ilist)
{
item * itm;
for (itm=ilist;itm;itm=itm->next) if (itm->number) {
whs(F, resourcename(itm->type->rtype, 0));
wi(F, itm->number);
fprintf(F, "%s %i ", resourcename(itm->type->rtype, 0), itm->number);
}
fputs("end ", F);
}

View File

@ -113,11 +113,9 @@ _log_error(const char * format, ...)
vfprintf(stderr, format, marker);
va_end(marker);
}
if (flags & LOG_FLUSH) {
log_flush();
log_flush();
}
}
}
void
_log_info(unsigned int flag, const char * format, ...)

View File

@ -1101,9 +1101,12 @@ check_phoenix(void)
}
}
f = findfaction(MONSTER_FACTION);
if (f==NULL) return;
/* it is not, so we create it */
r = random_land_region();
phoenix = createunit(r, findfaction(MONSTER_FACTION), 1, phoenix_race);
phoenix = createunit(r, f, 1, phoenix_race);
phoenix->name = strdup("Der Phönix");
/* TODO: generate an appropriate region message */

View File

@ -105,6 +105,13 @@ lua_setstring(const char * lname, const char * key, const char * str)
locale_setstring(lang, key, str);
}
static const char *
lua_getstring(const char * lname, const char * key)
{
struct locale * lang = find_locale(lname);
return locale_getstring(lang, key);
}
void
bind_eressea(lua_State * L)
{
@ -120,7 +127,10 @@ bind_eressea(lua_State * L)
def("add_equipment", &lua_addequipment),
def("get_turn", &get_turn),
def("remove_empty_units", &remove_empty_units),
/* localization: */
def("set_string", &lua_setstring),
def("get_string", &lua_getstring),
def("set_flag", &set_flag),
def("get_flag", &get_flag),

View File

@ -270,7 +270,25 @@ unit_setmagic(unit& u, const char * type)
static void
unit_addorder(unit& u, const char * str)
{
addstrlist(&u.orders, str);
char buf[1024];
char * s = buf;
boolean quote = false;
while (*str) {
switch (*str) {
case '"':
quote=!quote;
break;
case ' ':
if (quote) *s++ = SPACE_REPLACEMENT;
else *s++ = ' ';
break;
default:
*s++ = *str;
}
++str;
}
*s=0;
addstrlist(&u.orders, buf);
u.faction->lastorders = turn;
}

View File

@ -627,6 +627,7 @@ main(int argc, char *argv[])
int i;
char zText[MAX_PATH];
global.data_version = RELEASE_VERSION;
sqlpatch = true;
log_open("eressea.log");
printf("\n%s PBEM host\n"