fixoring compilation

BUG: dying factions got screwy spellbooks
BUG: monsters should not die
This commit is contained in:
Enno Rehling 2009-07-29 17:17:34 +00:00
parent 9b073f22fd
commit d956c2ec4b
6 changed files with 29 additions and 15 deletions

View File

@ -41,7 +41,7 @@
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
AdditionalOptions="/MP" AdditionalOptions="/MP"
Optimization="0" Optimization="0"
AdditionalIncludeDirectories="..;." AdditionalIncludeDirectories="..;../common;../external"
PreprocessorDefinitions="WIN32;_CRT_SECURE_NO_DEPRECATE" PreprocessorDefinitions="WIN32;_CRT_SECURE_NO_DEPRECATE"
MinimalRebuild="true" MinimalRebuild="true"
BasicRuntimeChecks="3" BasicRuntimeChecks="3"
@ -176,7 +176,7 @@
<Tool <Tool
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
Optimization="3" Optimization="3"
AdditionalIncludeDirectories="..;." AdditionalIncludeDirectories="..;../common;../external"
PreprocessorDefinitions="WIN32;_CRT_SECURE_NO_DEPRECATE;NDEBUG" PreprocessorDefinitions="WIN32;_CRT_SECURE_NO_DEPRECATE;NDEBUG"
StringPooling="true" StringPooling="true"
RuntimeLibrary="2" RuntimeLibrary="2"
@ -500,6 +500,10 @@
RelativePath=".\kernel\spellid.h" RelativePath=".\kernel\spellid.h"
> >
</File> </File>
<File
RelativePath=".\kernel\sqlite.c"
>
</File>
<File <File
RelativePath=".\kernel\teleport.c" RelativePath=".\kernel\teleport.c"
> >

View File

@ -92,6 +92,7 @@ get_monsters(void)
{ {
static faction * monsters; static faction * monsters;
static int gamecookie = -1; static int gamecookie = -1;
if (gamecookie!=global.cookie) { if (gamecookie!=global.cookie) {
monsters = NULL; monsters = NULL;
gamecookie = global.cookie; gamecookie = global.cookie;
@ -104,11 +105,13 @@ get_monsters(void)
return monsters=f; return monsters=f;
} }
} }
} if (!monsters) {
if (monsters==NULL) { /* shit! */
/* shit! */ monsters = findfaction(666);
monsters = findfaction(666); }
if (monsters) fset(monsters, FFL_NPC); if (monsters) {
fset(monsters, FFL_NPC|FFL_NOIDLEOUT);
}
} }
return monsters; return monsters;
} }
@ -272,6 +275,7 @@ destroyfaction(faction * f)
fset(f, FFL_QUIT); fset(f, FFL_QUIT);
freelist(f->spellbook); freelist(f->spellbook);
f->spellbook = NULL;
while (f->battles) { while (f->battles) {
struct bmsg * bm = f->battles; struct bmsg * bm = f->battles;
@ -466,7 +470,8 @@ boolean valid_race(const struct faction * f, const struct race * rc)
if (f->race==rc) return true; if (f->race==rc) return true;
else { else {
const char * str = get_param(f->race->parameters, "other_race"); const char * str = get_param(f->race->parameters, "other_race");
return (str?rc_find(str)==rc:false); if (str) return (boolean)(rc_find(str)==rc);
return false;
} }
} }

View File

@ -1260,6 +1260,7 @@ readfaction(struct storage * store)
} }
} }
read_groups(store, f); read_groups(store, f);
f->spellbook = NULL;
read_spellist(&f->spellbook, store); read_spellist(&f->spellbook, store);
return f; return f;
} }

View File

@ -4,6 +4,7 @@
#include <util/unicode.h> #include <util/unicode.h>
#include <sqlite3.h> #include <sqlite3.h>
#include <md5.h> #include <md5.h>
#include <assert.h>
faction * get_faction_by_id(int uid) faction * get_faction_by_id(int uid)
{ {
@ -28,7 +29,7 @@ db_update_factions(sqlite3 * db)
"INSERT OR IGNORE email (email,md5) VALUES (?,?)"; "INSERT OR IGNORE email (email,md5) VALUES (?,?)";
const char * sql_select_email = const char * sql_select_email =
"SELECT id FROM email WHERE md5=?"; "SELECT id FROM email WHERE md5=?";
const char * sql_update_faction = const char sql_update_faction[] =
"UPDATE faction SET email_id=?, lastturn=?, no=? WHERE id=?"; "UPDATE faction SET email_id=?, lastturn=?, no=? WHERE id=?";
faction * f; faction * f;
@ -38,13 +39,13 @@ db_update_factions(sqlite3 * db)
sqlite3_stmt *stmt_select; sqlite3_stmt *stmt_select;
int res; int res;
res = sqlite3_prepare_v2(db, sql_select_email, strlen(sql_select_email)+1, &stmt_select_email, NULL); res = sqlite3_prepare_v2(db, sql_select_email, (int)strlen(sql_select_email)+1, &stmt_select_email, NULL);
if (res!=SQLITE_OK) return res; if (res!=SQLITE_OK) return res;
res = sqlite3_prepare_v2(db, sql_insert_email, strlen(sql_insert_email)+1, &stmt_insert_email, NULL); res = sqlite3_prepare_v2(db, sql_insert_email, (int)strlen(sql_insert_email)+1, &stmt_insert_email, NULL);
if (res!=SQLITE_OK) return res; if (res!=SQLITE_OK) return res;
res = sqlite3_prepare_v2(db, sql_select, strlen(sql_select)+1, &stmt_select, NULL); res = sqlite3_prepare_v2(db, sql_select, (int)strlen(sql_select)+1, &stmt_select, NULL);
if (res!=SQLITE_OK) return res; if (res!=SQLITE_OK) return res;
res = sqlite3_prepare_v2(db, sql_update_faction, strlen(sql_update_faction)+1, &stmt_update_faction, NULL); res = sqlite3_prepare_v2(db, sql_update_faction, sizeof(sql_update_faction), &stmt_update_faction, NULL);
if (res!=SQLITE_OK) return res; if (res!=SQLITE_OK) return res;
res = sqlite3_bind_int(stmt_select, 1, game_id); res = sqlite3_bind_int(stmt_select, 1, game_id);
@ -75,7 +76,7 @@ db_update_factions(sqlite3 * db)
int i; int i;
md5_init(&ms); md5_init(&ms);
md5_append(&ms, (md5_byte_t*)lower, strlen(lower)); md5_append(&ms, (md5_byte_t*)lower, (int)strlen(lower));
md5_finish(&ms, digest); md5_finish(&ms, digest);
for (i=0;i!=16;++i) sprintf(md5hash+2*i, "%.02x", digest[i]); for (i=0;i!=16;++i) sprintf(md5hash+2*i, "%.02x", digest[i]);

View File

@ -332,6 +332,10 @@
RelativePath=".\tolua\bind_ship.h" RelativePath=".\tolua\bind_ship.h"
> >
</File> </File>
<File
RelativePath=".\tolua\bind_sqlite.c"
>
</File>
<File <File
RelativePath=".\tolua\bind_storage.c" RelativePath=".\tolua\bind_storage.c"
> >

View File

@ -599,7 +599,6 @@ tolua_region_open(lua_State* L)
tolua_function(L, TOLUA_CAST "get_key", tolua_region_getkey); tolua_function(L, TOLUA_CAST "get_key", tolua_region_getkey);
tolua_function(L, TOLUA_CAST "set_key", tolua_region_setkey); tolua_function(L, TOLUA_CAST "set_key", tolua_region_setkey);
#if 0 #if 0
.property("owner", &lua_region_getowner, &lua_region_setowner)
.property("herbtype", &region_getherbtype, &region_setherbtype) .property("herbtype", &region_getherbtype, &region_setherbtype)
.def("add_notice", &region_addnotice) .def("add_notice", &region_addnotice)
.def("add_direction", &region_adddirection) .def("add_direction", &region_adddirection)