sql fixes? race update

This commit is contained in:
Enno Rehling 2009-08-02 22:10:39 +00:00
parent 61b0c7228a
commit 1b6a6d9bd1
5 changed files with 14 additions and 6 deletions

View File

@ -3632,9 +3632,9 @@ age_factions(void)
for (f = factions; f; f = f->next) {
++f->age;
if (f->age < NewbieImmunity()) {
if (f->age+1 < NewbieImmunity()) {
ADDMSG(&f->msgs, msg_message("newbieimmunity", "turns",
NewbieImmunity() - f->age));
NewbieImmunity() - f->age - 1));
}
}
}

View File

@ -2364,7 +2364,7 @@ static double horsebonus(const unit * u)
it_charger = it_find("charger");
}
while (itm) {
for (;itm;itm=itm->next) {
if (itm->type->flags&ITF_ANIMAL) {
if (itm->type==it_elvenhorse) n3 +=itm->number;
else if (itm->type==it_charger) n2 +=itm->number;

View File

@ -236,6 +236,7 @@ db_update_scores(sqlite3 * db, boolean force)
const char * sql_upd = "UPDATE score set value=? WHERE faction_id=? AND turn=?";
sqlite3_stmt * stmt_upd = stmt_cache_get(db, sql_upd);
faction * f;
sqlite3_exec(db, "BEGIN", 0, 0, 0);
for (f=factions;f;f=f->next) {
int res;
sqlite3_bind_int(stmt_ins, 1, f->score);
@ -249,8 +250,8 @@ db_update_scores(sqlite3 * db, boolean force)
res = sqlite3_step(stmt_upd);
sqlite3_reset(stmt_upd);
}
SQL_EXPECT(res, SQLITE_DONE);
sqlite3_reset(stmt_ins);
}
sqlite3_exec(db, "COMMIT", 0, 0, 0);
return SQLITE_OK;
}
}

View File

@ -113,7 +113,7 @@
<skill name="taxation" enable="false"/>
<skill name="trade" enable="false"/>
<param name="NewbieImmunity" value="8"/>
<param name="NewbieImmunity" value="9"/> <!-- ends after turn 9 -->
<param name="modules.astralspace" value="0"/>
<param name="modules.wormholes" value="0"/>

View File

@ -197,6 +197,7 @@ function process(orders)
-- use newfactions file to place out new players
-- autoseed(basepath .. "/newfactions", false)
read_xml(resourcepath.."/e3a-update.xml")
write_files(locales)
write_statistics()
@ -211,6 +212,11 @@ end
--
-- main body of script
--
function dbupdate()
edb = db.open(basepath.."/eressea.db")
edb:update_factions()
edb:update_scores()
end
-- orderfile: contains the name of the orders.
load_scripts()
@ -218,4 +224,5 @@ if orderfile==nil then
print "you must specify an orderfile"
else
process(orderfile)
dbupdate()
end