Renaming a lot of the HSE script files, because they are more generic than I

thought they would be and can be reused.

Added HSE4 rules files.

Added sorting by Race to the mapper's newfaction list, which might be a bad
idea for automated seeding.
This commit is contained in:
Enno Rehling 2005-02-18 09:34:12 +00:00
parent b9aabcc944
commit 03b2543d30
10 changed files with 188 additions and 53 deletions

View File

@ -231,54 +231,59 @@ read_newfactions(const char * filename)
FILE * F = fopen(filename, "r");
if (F==NULL) return;
for (;;) {
faction * f = factions;
char race[20], email[64], lang[8], password[16];
newfaction *nf;
int bonus, subscription;
int alliance = 0;
if (alliances!=NULL) {
/* email;race;locale;startbonus;subscription;alliance */
if (fscanf(F, "%s %s %s %d %d %s %d", email, race, lang, &bonus, &subscription, password, &alliance)<=0) break;
} else {
/* email;race;locale;startbonus;subscription */
if (fscanf(F, "%s %s %s %d %d %s", email, race, lang, &bonus, &subscription, password)<=0) break;
}
while (f) {
if (strcmp(f->email, email)==0 && f->subscription) {
break;
}
f = f->next;
}
if (f) continue; /* skip the ones we've already got */
for (nf=newfactions;nf;nf=nf->next) {
if (strcmp(nf->email, email)==0) break;
}
if (nf) continue;
nf = calloc(sizeof(newfaction), 1);
if (set_email(&nf->email, email)!=0) {
log_error(("Invalid email address for subscription %s: %s\n", itoa36(subscription), email));
}
nf->password = strdup(password);
nf->race = rc_find(race);
nf->subscription = subscription;
if (alliances!=NULL) {
struct alliance * al = findalliance(alliance);
if (al==NULL) {
char zText[64];
sprintf(zText, "Allianz %d", alliance);
al = makealliance(alliance, zText);
}
nf->allies = al;
} else {
nf->allies = NULL;
}
if (nf->race==NULL) nf->race = findrace(race, default_locale);
nf->lang = find_locale(lang);
nf->bonus = bonus;
assert(nf->race && nf->email && nf->lang);
nf->next = newfactions;
newfactions = nf;
faction * f = factions;
char race[20], email[64], lang[8], password[16];
newfaction *nf, **nfi;
int bonus, subscription;
int alliance = 0;
if (alliances!=NULL) {
/* email;race;locale;startbonus;subscription;alliance */
if (fscanf(F, "%s %s %s %d %d %s %d", email, race, lang, &bonus, &subscription, password, &alliance)<=0) break;
} else {
/* email;race;locale;startbonus;subscription */
if (fscanf(F, "%s %s %s %d %d %s", email, race, lang, &bonus, &subscription, password)<=0) break;
}
while (f) {
if (strcmp(f->email, email)==0 && f->subscription) {
break;
}
f = f->next;
}
if (f) continue; /* skip the ones we've already got */
for (nf=newfactions;nf;nf=nf->next) {
if (strcmp(nf->email, email)==0) break;
}
if (nf) continue;
nf = calloc(sizeof(newfaction), 1);
if (set_email(&nf->email, email)!=0) {
log_error(("Invalid email address for subscription %s: %s\n", itoa36(subscription), email));
}
nf->password = strdup(password);
nf->race = rc_find(race);
nf->subscription = subscription;
if (alliances!=NULL) {
struct alliance * al = findalliance(alliance);
if (al==NULL) {
char zText[64];
sprintf(zText, "Allianz %d", alliance);
al = makealliance(alliance, zText);
}
nf->allies = al;
} else {
nf->allies = NULL;
}
if (nf->race==NULL) nf->race = findrace(race, default_locale);
nf->lang = find_locale(lang);
nf->bonus = bonus;
assert(nf->race && nf->email && nf->lang);
nfi = &newfactions;
while (*nfi) {
if ((*nfi)->race==nf->race) break;
nfi=&(*nfi)->next;
}
nf->next = *nfi;
*nfi = nf;
}
fclose(F);
}

56
src/res/hse4.xml Normal file
View File

@ -0,0 +1,56 @@
<?xml version="1.0"?>
<eressea xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:include href="messages.xml"/>
<!-- Localization -->
<xi:include href="de/strings.xml"/>
<xi:include href="en/strings.xml"/>
<xi:include href="resources.xml"/>
<xi:include href="races.xml"/>
<xi:include href="prefixes.xml"/>
<xi:include href="ships.xml"/>
<xi:include href="buildings.xml"/>
<xi:include file="terrains.xml"/>
<xi:include file="alchemy.xml"/>
<xi:include file="technologies.xml"/>
<xi:include file="skills.xml"/>
<equipment>
<item name="wood" amount="5"/>
<item name="stone" amount="10"/>
</equipment>
<game name="HSE4" welcome="eressea">
<comment>Game specific</comment>
<order name="MEINUNG" disable="yes"/>
<order name="NUMMER" disable="yes"/>
<order name="MAGIEGEBIET" disable="yes"/>
<param name="entertain.base" value="15"/>
<param name="entertain.perlevel" value="5"/>
<param name="nmr.timeout" value="20"/>
<param name="nmr.removenewbie" value="0"/>
<param name="GiveRestriction" value="3"/>
<param name="NewbieImmunity" value="4"/>
<param name="hunger.long" value="1"/>
<param name="database.gameid" value="6"/>
<param name="globalreport" value="world"/>
<param name="rules.check_overload" value="1"/>
<param name="report.mailit" value="/usr/sbin:$HOME/eressea/bin:/bin:/usr/bin:/usr/local/bin"/>
</game>
<xi:include href="eressea/de/strings.xml"/>
<xi:include href="eressea/en/strings.xml"/>
<xi:include href="eressea/races.xml"/>
<xi:include href="eressea/items-hse.xml"/>
<xi:include href="eressea/dungeons.xml"/>
<xi:include href="eressea/temple.xml"/>
<strings>
<string name="mailto">
<text locale="de">hse-server@eressea.de</text>
<text locale="en">hse-server@eressea.de</text>
</string>
<string name="mailcmd">
<text locale="de">ERESSEA BEFEHLE</text>
<text locale="en">ERESSEA ORDERS</text>
</string>
</strings>
</eressea>

View File

@ -1,6 +1,6 @@
dofile(scriptpath .. "/hse05-grails.lua")
dofile(scriptpath .. "/hse05-spoils.lua")
dofile(scriptpath .. "/hse05-buildings.lua")
dofile(scriptpath .. "/hse-grails.lua")
dofile(scriptpath .. "/hse-spoils.lua")
dofile(scriptpath .. "/hse-buildings.lua")
function write_stats(filename)
local file = io.open(reportpath .. "/" .. filename, "w")

View File

@ -1,7 +1,7 @@
function run_scripts()
scripts = {
"hse05-portals.lua",
"hse05-stats.lua"
"hse-portals.lua",
"hse-stats.lua"
}
for index in scripts do
local script = scriptpath .. "/" .. scripts[index]

74
src/scripts/hse4-run.lua Normal file
View File

@ -0,0 +1,74 @@
function run_scripts()
scripts = {
"hse-portals.lua",
"hse-stats.lua"
}
for index in scripts do
local script = scriptpath .. "/" .. scripts[index]
print("- loading " .. script)
if pcall(dofile, script)==0 then
print("Could not load " .. script)
end
end
end
function write_emails()
local locales = { "de", "en" }
local files = {}
local key
for key in locales do
local locale = locales[key]
files[locale] = io.open(basepath .. "/emails." .. locale, "w")
end
local faction
for faction in factions() do
-- print(faction.id .. " - " .. faction.locale)
files[faction.locale]:write(faction.email .. "\n")
end
for key in files do
files[key]:close()
end
end
function process(orders)
file = "" .. get_turn()
if read_game(file)~=0 then
print("could not read game")
return -1
end
-- run the turn:
read_orders(orders)
run_scripts()
plan_monsters()
process_orders()
write_passwords()
write_reports()
write_emails()
file = "" .. get_turn()
if write_game(file)~=0 then
print("could not write game")
return -1
end
write_stats("grails.txt")
end
--
-- main body of script
--
-- orderfile: contains the name of the orders.
if orderfile==nil then
print "you must specify an orderfile"
else
process(orderfile)
end