From fa98528d72cf99971c8bad32a54a4edd14a9ead7 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 11 Jun 2014 21:25:24 -0700 Subject: [PATCH] remove old SQL patch code, we have sqlite now. rearrange the SlickEdit projects. --- se/Eressea.vpw | 1 + se/eressea.vpj | 1114 +++++++++++++++++++------------------- se/server.vpj | 316 +++++++++++ src/CMakeLists.txt | 4 +- src/bindings.c | 2 +- src/{util => }/console.c | 0 src/{util => }/console.h | 0 src/gmtool.c | 4 +- src/kernel/config.c | 14 - src/kernel/faction.c | 5 - src/kernel/save.c | 1 - src/laws.c | 12 - src/modules/autoseed.c | 8 - src/util/CMakeLists.txt | 2 - src/util/sql.c | 82 --- src/util/sql.h | 35 -- 16 files changed, 874 insertions(+), 726 deletions(-) create mode 100644 se/server.vpj rename src/{util => }/console.c (100%) rename src/{util => }/console.h (100%) delete mode 100644 src/util/sql.c delete mode 100644 src/util/sql.h diff --git a/se/Eressea.vpw b/se/Eressea.vpw index eecc1e451..273ff906a 100644 --- a/se/Eressea.vpw +++ b/se/Eressea.vpw @@ -2,6 +2,7 @@ + diff --git a/se/eressea.vpj b/se/eressea.vpj index 46026fe38..cdfe0d2c0 100644 --- a/se/eressea.vpj +++ b/se/eressea.vpj @@ -1,566 +1,554 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + Version="10.0" + VendorName="SlickEdit" + TemplateName="GNU C/C++" + WorkingDir="." + BuildSystem="vsbuild" + VCSProject="Git:"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/se/server.vpj b/se/server.vpj new file mode 100644 index 000000000..1f795b4f9 --- /dev/null +++ b/se/server.vpj @@ -0,0 +1,316 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 45a191a8b..d52c220ef 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -81,6 +81,8 @@ set (ERESSEA_SRC ) set(SERVER_SRC + main.c + console.c helpers.c process.pkg.c eressea.pkg.c @@ -115,7 +117,7 @@ set (SERVER_SRC ${SERVER_SRC}) endif(CURSES_FOUND) -add_executable(eressea ${SERVER_SRC} main.c) +add_executable(eressea ${SERVER_SRC}) target_link_libraries(eressea ${TOLUA_LIBRARIES} ${LUA_LIBRARIES} diff --git a/src/bindings.c b/src/bindings.c index 70a726a55..e63499068 100755 --- a/src/bindings.c +++ b/src/bindings.c @@ -23,6 +23,7 @@ without prior permission by the authors of Eressea. #include "bind_gmtool.h" #include "bind_region.h" #include "helpers.h" +#include "console.h" #include @@ -61,7 +62,6 @@ without prior permission by the authors of Eressea. #include #include -#include #include #include #include diff --git a/src/util/console.c b/src/console.c similarity index 100% rename from src/util/console.c rename to src/console.c diff --git a/src/util/console.h b/src/console.h similarity index 100% rename from src/util/console.h rename to src/console.h diff --git a/src/gmtool.c b/src/gmtool.c index df76b6965..7db2a13a3 100644 --- a/src/gmtool.c +++ b/src/gmtool.c @@ -15,6 +15,8 @@ #include "gmtool.h" #include "gmtool_structs.h" +#include "console.h" +#include "listbox.h" #include #include @@ -56,8 +58,6 @@ #include #include #include -#include -#include #include #include diff --git a/src/kernel/config.c b/src/kernel/config.c index 9b9af1f62..fe5c89b5f 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -67,7 +67,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include -#include #include #include #include @@ -100,7 +99,6 @@ bool lomem = false; FILE *logfile; FILE *updatelog; const struct race *new_race[MAXRACES]; -bool sqlpatch = false; bool battledebug = false; int turn = -1; @@ -2172,7 +2170,6 @@ void kernel_done(void) */ translation_done(); gc_done(); - sql_done(); } const char *localenames[] = { @@ -2316,10 +2313,6 @@ void remove_empty_factions(void) } } } - if (f->subscription) { - sql_print(("UPDATE subscriptions set status='DEAD' where id=%u;\n", - f->subscription)); - } *fp = f->next; funhash(f); @@ -3012,14 +3005,8 @@ void attrib_init(void) void kernel_init(void) { - char zBuffer[MAX_PATH]; attrib_init(); translation_init(); - - if (sqlpatch) { - sprintf(zBuffer, "%s/patch-%d.sql", datapath(), turn); - sql_init(zBuffer); - } } static order * defaults[MAXLOCALES]; @@ -3147,7 +3134,6 @@ void load_inifile(dictionary * d) } verbosity = iniparser_getint(d, "eressea:verbose", 2); - sqlpatch = iniparser_getint(d, "eressea:sqlpatch", false); battledebug = iniparser_getint(d, "eressea:debug", battledebug) ? 1 : 0; str = iniparser_getstring(d, "eressea:locales", "de,en"); diff --git a/src/kernel/faction.c b/src/kernel/faction.c index 5d8f886b1..c1ff3cb83 100755 --- a/src/kernel/faction.c +++ b/src/kernel/faction.c @@ -46,7 +46,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include -#include #include #include #include @@ -419,10 +418,6 @@ void set_alliance(faction * a, faction * b, int status) void renumber_faction(faction * f, int no) { - if (f->subscription) { - sql_print(("UPDATE subscriptions set faction='%s' where id=%u;\n", - itoa36(no), f->subscription)); - } funhash(f); f->no = no; fhash(f); diff --git a/src/kernel/save.c b/src/kernel/save.c index 5bc26a84c..ad1ce1fb3 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -66,7 +66,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include -#include #include #include diff --git a/src/laws.c b/src/laws.c index a95aa7a33..4ec82da73 100755 --- a/src/laws.c +++ b/src/laws.c @@ -80,7 +80,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include -#include #include #include #include @@ -1448,17 +1447,6 @@ static void remove_idle_players(void) char info[256]; sprintf(info, "%d Einheiten, %d Personen, %d Silber", f->no_units, f->num_total, f->money); - if (f->subscription) { - sql_print( - ("UPDATE subscriptions SET lastturn=%d, info='%s' WHERE id=%u;\n", - f->lastorders, info, f->subscription)); - } - } else { - if (f->subscription) { - sql_print( - ("UPDATE subscriptions SET status='ACTIVE', lastturn=%d, firstturn=greatest(firstturn,%d) WHERE id=%u;\n", - f->lastorders, f->lastorders - f->age, f->subscription)); - } } if (NMRTimeout() > 0 && turn - f->lastorders >= (NMRTimeout() - 1)) { diff --git a/src/modules/autoseed.c b/src/modules/autoseed.c index 862bd5768..19ee1e662 100644 --- a/src/modules/autoseed.c +++ b/src/modules/autoseed.c @@ -37,7 +37,6 @@ #include #include #include -#include #include /* libc includes */ @@ -685,13 +684,6 @@ int autoseed(newfaction ** players, int nsize, int max_agediff) f = u->faction; fset(f, FFL_ISNEW); f->alliance = nextf->allies; - log_printf(stdout, "New faction (%s), %s at %s\n", itoa36(f->no), - f->email, regionname(r, NULL)); - if (f->subscription) { - sql_print( - ("UPDATE subscriptions SET status='ACTIVE', faction='%s', firstturn=%d, lastturn=%d WHERE id=%u;\n", - factionid(f), f->lastorders, f->lastorders, f->subscription)); - } /* remove duplicate email addresses */ nfp = &nextf->next; diff --git a/src/util/CMakeLists.txt b/src/util/CMakeLists.txt index 8209daceb..ac67e1853 100644 --- a/src/util/CMakeLists.txt +++ b/src/util/CMakeLists.txt @@ -11,7 +11,6 @@ SET(_FILES attrib.c base36.c bsdstring.c -console.c crmessage.c dice.c event.c @@ -26,7 +25,6 @@ nrmessage.c parser.c rand.c resolve.c -sql.c strings.c translation.c umlaut.c diff --git a/src/util/sql.c b/src/util/sql.c deleted file mode 100644 index a91d57a5a..000000000 --- a/src/util/sql.c +++ /dev/null @@ -1,82 +0,0 @@ -/* -Copyright (c) 1998-2010, Enno Rehling - Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - -#include -#include "sql.h" - -#include "log.h" - -#include -#include -#include -#include - -static FILE *sqlstream = NULL; -static char *sqlfilename = NULL; - -void sql_init(const char *filename) -{ - if (sqlfilename != NULL) - free(sqlfilename); - sqlfilename = _strdup(filename); -} - -void _sql_print(const char *format, ...) -{ - if (!sqlstream && sqlfilename) { - sqlstream = fopen(sqlfilename, "wt+"); - free(sqlfilename); - sqlfilename = NULL; - } - if (sqlstream != NULL) { - va_list marker; - va_start(marker, format); - vfprintf(sqlstream, format, marker); - va_end(marker); - } -} - -void sql_done(void) -{ - if (sqlstream) - fclose(sqlstream); - if (sqlfilename) - free(sqlfilename); - sqlstream = NULL; - sqlfilename = NULL; -} - -const char *sqlquote(const char *str) -{ -#define BUFFERS 4 -#define BUFSIZE 1024 - static char sqlstring[BUFSIZE * BUFFERS]; /* STATIC_RESULT: used for return, not across calls */ - static int index = 0; /* STATIC_XCALL: used across calls */ - char *start = sqlstring + index * BUFSIZE; - char *o = start; - const char *i = str; - while (*i && o - start < BUFSIZE - 1) { - if (*i != '\'' && *i != '\"') { - *o++ = *i++; - } else - ++i; - } - *o = '\0'; - index = (index + 1) % BUFFERS; - return start; -} diff --git a/src/util/sql.h b/src/util/sql.h deleted file mode 100644 index 2cbc9f5a1..000000000 --- a/src/util/sql.h +++ /dev/null @@ -1,35 +0,0 @@ -/* -Copyright (c) 1998-2010, Enno Rehling - Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - -#ifndef H_UTIL_SQL -#define H_UTIL_SQL -#ifdef __cplusplus -extern "C" { -#endif - - extern void sql_init(const char *filename); - extern void sql_done(void); - extern const char *sqlquote(const char *str); - extern void _sql_print(const char *format, ...); - -#define sql_print(x) _sql_print x - -#ifdef __cplusplus -} -#endif -#endif