forked from github/server
Logging Funktionen für den Mapper. save.c exportiert funktionen, um einheiten zu laden und zu speichern.
Muss noch in den Mapper an allen möglichen Stellen eingebaut werden, und natuerlich getestet werden.
This commit is contained in:
parent
c42b27d211
commit
39247a6133
|
@ -2285,9 +2285,6 @@ attrib_init(void)
|
||||||
register_bordertype(&bt_wisps);
|
register_bordertype(&bt_wisps);
|
||||||
register_bordertype(&bt_road);
|
register_bordertype(&bt_road);
|
||||||
|
|
||||||
#if USE_EVENTS
|
|
||||||
at_register(&at_events);
|
|
||||||
#endif
|
|
||||||
at_register(&at_jihad);
|
at_register(&at_jihad);
|
||||||
at_register(&at_skillmod);
|
at_register(&at_skillmod);
|
||||||
#if GROWING_TREES
|
#if GROWING_TREES
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -66,4 +66,13 @@ extern const char * datapath(void);
|
||||||
extern struct attrib_type at_resources;
|
extern struct attrib_type at_resources;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
extern void writeunit(FILE * stream, const struct unit * u);
|
||||||
|
extern struct unit * readunit(FILE * stream);
|
||||||
|
|
||||||
|
extern void writeregion(FILE * stream, const struct region * r);
|
||||||
|
extern struct region * readregion(FILE * stream, int x, int y);
|
||||||
|
|
||||||
|
extern void writefaction(FILE * stream, const struct faction * f);
|
||||||
|
extern struct faction * readfaction(FILE * stream);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -0,0 +1,100 @@
|
||||||
|
/* vi: set ts=2:
|
||||||
|
+-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||||
|
| | Enno Rehling <enno@eressea-pbem.de>
|
||||||
|
| Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
||||||
|
| (c) 1998 - 2001 | Henning Peters <faroul@beyond.kn-bremen.de>
|
||||||
|
| | Ingo Wilken <Ingo.Wilken@informatik.uni-oldenburg.de>
|
||||||
|
+-------------------+ Stefan Reich <reich@halbling.de>
|
||||||
|
|
||||||
|
This program may not be used, modified or distributed
|
||||||
|
without prior permission by the authors of Eressea.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
#include <eressea.h>
|
||||||
|
|
||||||
|
/* kernel includes */
|
||||||
|
#include <faction.h>
|
||||||
|
#include <unit.h>
|
||||||
|
#include <region.h>
|
||||||
|
#include <save.h>
|
||||||
|
|
||||||
|
/* util includes */
|
||||||
|
#include <base36.h>
|
||||||
|
|
||||||
|
/* libc includes */
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
static FILE * log;
|
||||||
|
|
||||||
|
void
|
||||||
|
readlog(FILE * log)
|
||||||
|
{
|
||||||
|
faction **fp = &factions;
|
||||||
|
char buf[64];
|
||||||
|
|
||||||
|
while (*fp) fp=&(*fp)->next;
|
||||||
|
fscanf(log, "LOGVERSION %d\n", &global.data_version);
|
||||||
|
while (!feof(log)) {
|
||||||
|
fscanf(log, "%s", buf);
|
||||||
|
if (strcmp(buf, "UNIT")==0) {
|
||||||
|
int x, y;
|
||||||
|
unit * u;
|
||||||
|
region * r;
|
||||||
|
fscanf(log, "%s %d %d", buf, &x, &y);
|
||||||
|
u = readunit(log);
|
||||||
|
r = findregion(x, y);
|
||||||
|
assert(r);
|
||||||
|
if (u->region!=r) move_unit(u, r, NULL);
|
||||||
|
} else if (strcmp(buf, "REGION")) {
|
||||||
|
int x, y;
|
||||||
|
fscanf(log, "%d %d", &x, &y);
|
||||||
|
readregion(log, x, y);
|
||||||
|
} else if (strcmp(buf, "FACTION")) {
|
||||||
|
faction * f;
|
||||||
|
fscanf(log, "%s", buf);
|
||||||
|
f = findfaction(atoi36(buf));
|
||||||
|
if (f) {
|
||||||
|
readfaction(log);
|
||||||
|
} else {
|
||||||
|
*fp = readfaction(log);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
log_faction(const struct faction * f)
|
||||||
|
{
|
||||||
|
fprintf(log, "FACTION %s", factionid(f));
|
||||||
|
writefaction(log, f);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
log_unit(const struct unit * u)
|
||||||
|
{
|
||||||
|
fprintf(log, "UNIT %s %d %d", unitid(u), u->region->x, u->region->y);
|
||||||
|
writeunit(log, u);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
log_region(const struct region * r)
|
||||||
|
{
|
||||||
|
fprintf(log, "REGION %d %d\n", r->x, r->y);
|
||||||
|
writeregion(log, r);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
log_start(const char * filename)
|
||||||
|
{
|
||||||
|
log = fopen(filename, "w+");
|
||||||
|
fprintf(log, "LOGVERSION %d\n", RELEASE_VERSION);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
log_stop(void)
|
||||||
|
{
|
||||||
|
fclose(log);
|
||||||
|
log = NULL;
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
#ifndef _LOGGING_H
|
||||||
|
#define _LOGGING_H
|
||||||
|
|
||||||
|
/* vi: set ts=2:
|
||||||
|
+-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||||
|
| | Enno Rehling <enno@eressea-pbem.de>
|
||||||
|
| Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
||||||
|
| (c) 1998 - 2001 | Henning Peters <faroul@beyond.kn-bremen.de>
|
||||||
|
| | Ingo Wilken <Ingo.Wilken@informatik.uni-oldenburg.de>
|
||||||
|
+-------------------+ Stefan Reich <reich@halbling.de>
|
||||||
|
|
||||||
|
This program may not be used, modified or distributed
|
||||||
|
without prior permission by the authors of Eressea.
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern void readlog(FILE * log);
|
||||||
|
extern void log_region(const struct region * r);
|
||||||
|
extern void log_unit(const struct unit * r);
|
||||||
|
extern void log_faction(const struct faction * f);
|
||||||
|
extern void log_start(const char * filename);
|
||||||
|
extern void log_stop(void);
|
||||||
|
|
||||||
|
#endif /* _LOGGING_H */
|
|
@ -8,12 +8,12 @@ CFG=mapper - Win32 Debug
|
||||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||||
!MESSAGE use the Export Makefile command and run
|
!MESSAGE use the Export Makefile command and run
|
||||||
!MESSAGE
|
!MESSAGE
|
||||||
!MESSAGE NMAKE /f "mapper-6.mak".
|
!MESSAGE NMAKE /f "mapper.mak".
|
||||||
!MESSAGE
|
!MESSAGE
|
||||||
!MESSAGE You can specify a configuration when running NMAKE
|
!MESSAGE You can specify a configuration when running NMAKE
|
||||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||||
!MESSAGE
|
!MESSAGE
|
||||||
!MESSAGE NMAKE /f "mapper-6.mak" CFG="mapper - Win32 Debug"
|
!MESSAGE NMAKE /f "mapper.mak" CFG="mapper - Win32 Debug"
|
||||||
!MESSAGE
|
!MESSAGE
|
||||||
!MESSAGE Possible choices for configuration are:
|
!MESSAGE Possible choices for configuration are:
|
||||||
!MESSAGE
|
!MESSAGE
|
||||||
|
@ -74,7 +74,7 @@ BSC32=bscmake.exe
|
||||||
# ADD BSC32 /nologo /S (*.h ../*.h ../common/kernel/*.h ../common/attributes/*.h ../common/spells/*.h ../common/triggers/*.h ../common/items/*.h ../common/modules/*.h ../common/util/*.h) ../common/util/Debug/*.sbr ../common/items/Debug/*.sbr ../common/attributes/Debug/*.sbr ../common/kernel/Debug/*.sbr ../common/spells/Debug/*.sbr ../common/modules/Debug/*.sbr
|
# ADD BSC32 /nologo /S (*.h ../*.h ../common/kernel/*.h ../common/attributes/*.h ../common/spells/*.h ../common/triggers/*.h ../common/items/*.h ../common/modules/*.h ../common/util/*.h) ../common/util/Debug/*.sbr ../common/items/Debug/*.sbr ../common/attributes/Debug/*.sbr ../common/kernel/Debug/*.sbr ../common/spells/Debug/*.sbr ../common/modules/Debug/*.sbr
|
||||||
LINK32=link.exe
|
LINK32=link.exe
|
||||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||||
# ADD LINK32 curses.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:console /debug /machine:I386 /out:"Debug/mapper.exe" /pdbtype:sept
|
# ADD LINK32 curses.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||||
|
|
||||||
!ENDIF
|
!ENDIF
|
||||||
|
|
||||||
|
@ -87,6 +87,10 @@ LINK32=link.exe
|
||||||
# PROP Default_Filter "*.h"
|
# PROP Default_Filter "*.h"
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\logging.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=.\mapper.h
|
SOURCE=.\mapper.h
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
@ -108,6 +112,10 @@ SOURCE=..\modules\weather.h
|
||||||
# End Group
|
# End Group
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\logging.c
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=.\map_modify.c
|
SOURCE=.\map_modify.c
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
Loading…
Reference in New Issue