forked from github/server
- tolua: destroying objects is good.
- begin taking care of multis.
This commit is contained in:
parent
9124a86e0e
commit
7563f57432
8 changed files with 112 additions and 18 deletions
|
@ -200,7 +200,7 @@ update_nmrs(void)
|
|||
for (f = factions; f; f = f->next) {
|
||||
if (fval(f, FFL_ISNEW)) {
|
||||
++newplayers;
|
||||
} else if (!is_monsters(f)) {
|
||||
} else if (!is_monsters(f) && f->alive) {
|
||||
int nmr = turn-f->lastorders+1;
|
||||
if (nmr<0 || nmr>NMRTimeout()) {
|
||||
log_error(("faction %s has %d NMRS\n", factionid(f), nmr));
|
||||
|
|
|
@ -6,8 +6,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "kernel", "common\kernel.vcp
|
|||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gamecode", "common\gamecode.vcproj", "{1E8BFF9E-3044-0742-992F-C5765B80FE65}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bindings", "eressea\lua\bindings.vcproj", "{74B1CBD4-3B6E-E544-9475-33FBB0BCE165}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "editor", "eressea\editor.vcproj", "{D893D6B3-805D-9848-8EA4-CDA1B79151F6}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "eressea-lua", "eressea\eressea-lua.vcproj", "{75501170-51C2-E641-BA8B-EDC008184192}"
|
||||
|
@ -16,7 +14,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "eressea-lua", "eressea\eres
|
|||
{F70CFB27-8A2F-E447-B452-4E1C590EDA6D} = {F70CFB27-8A2F-E447-B452-4E1C590EDA6D}
|
||||
{1E8BFF9E-3044-0742-992F-C5765B80FE65} = {1E8BFF9E-3044-0742-992F-C5765B80FE65}
|
||||
{D893D6B3-805D-9848-8EA4-CDA1B79151F6} = {D893D6B3-805D-9848-8EA4-CDA1B79151F6}
|
||||
{74B1CBD4-3B6E-E544-9475-33FBB0BCE165} = {74B1CBD4-3B6E-E544-9475-33FBB0BCE165}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "eressea", "eressea.vcproj", "{AD80EB0B-7CB4-42F2-9C95-8CCEF68DB387}"
|
||||
|
@ -44,10 +41,6 @@ Global
|
|||
{1E8BFF9E-3044-0742-992F-C5765B80FE65}.Profile|Win32.ActiveCfg = Profile|Win32
|
||||
{1E8BFF9E-3044-0742-992F-C5765B80FE65}.Profile|Win32.Build.0 = Profile|Win32
|
||||
{1E8BFF9E-3044-0742-992F-C5765B80FE65}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{74B1CBD4-3B6E-E544-9475-33FBB0BCE165}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{74B1CBD4-3B6E-E544-9475-33FBB0BCE165}.Profile|Win32.ActiveCfg = Profile|Win32
|
||||
{74B1CBD4-3B6E-E544-9475-33FBB0BCE165}.Profile|Win32.Build.0 = Profile|Win32
|
||||
{74B1CBD4-3B6E-E544-9475-33FBB0BCE165}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{D893D6B3-805D-9848-8EA4-CDA1B79151F6}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{D893D6B3-805D-9848-8EA4-CDA1B79151F6}.Profile|Win32.ActiveCfg = Profile|Win32
|
||||
{D893D6B3-805D-9848-8EA4-CDA1B79151F6}.Profile|Win32.Build.0 = Profile|Win32
|
||||
|
|
|
@ -274,6 +274,14 @@ tolua_faction_get_origin(lua_State* L)
|
|||
return 2;
|
||||
}
|
||||
|
||||
static int
|
||||
tolua_faction_destroy(lua_State* L)
|
||||
{
|
||||
faction* f = (faction*) tolua_tousertype(L, 1, 0);
|
||||
destroyfaction(f);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
tolua_faction_create(lua_State* L)
|
||||
{
|
||||
|
@ -482,8 +490,9 @@ tolua_faction_open(lua_State* L)
|
|||
tolua_function(L, TOLUA_CAST "add_item", tolua_faction_add_item);
|
||||
tolua_variable(L, TOLUA_CAST "items", tolua_faction_get_items, NULL);
|
||||
|
||||
tolua_function(L, TOLUA_CAST "renumber", tolua_faction_renumber);
|
||||
tolua_function(L, TOLUA_CAST "create", tolua_faction_create);
|
||||
tolua_function(L, TOLUA_CAST "renumber", &tolua_faction_renumber);
|
||||
tolua_function(L, TOLUA_CAST "create", &tolua_faction_create);
|
||||
tolua_function(L, TOLUA_CAST "destroy", &tolua_faction_destroy);
|
||||
#ifdef TODO
|
||||
def("faction_origin", &faction_getorigin, pure_out_value(_2) + pure_out_value(_3)),
|
||||
|
||||
|
|
|
@ -84,6 +84,20 @@ tolua_region_get_terrain(lua_State* L)
|
|||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
tolua_region_set_terrain(lua_State* L)
|
||||
{
|
||||
region* r = (region*) tolua_tousertype(L, 1, 0);
|
||||
const char * tname = tolua_tostring(L, 2, 0);
|
||||
if (tname) {
|
||||
const terrain_type * terrain = get_terrain(tname);
|
||||
if (terrain) {
|
||||
terraform_region(r, terrain);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
tolua_region_get_terrainname(lua_State* L)
|
||||
{
|
||||
|
@ -494,7 +508,7 @@ tolua_region_open(lua_State* L)
|
|||
tolua_variable(L, TOLUA_CAST "ships", tolua_region_get_ships, NULL);
|
||||
tolua_variable(L, TOLUA_CAST "age", tolua_region_get_age, NULL);
|
||||
tolua_variable(L, TOLUA_CAST "buildings", tolua_region_get_buildings, NULL);
|
||||
tolua_variable(L, TOLUA_CAST "terrain", tolua_region_get_terrain, NULL);
|
||||
tolua_variable(L, TOLUA_CAST "terrain", tolua_region_get_terrain, tolua_region_set_terrain);
|
||||
tolua_function(L, TOLUA_CAST "get_resourcelevel", tolua_region_get_resourcelevel);
|
||||
tolua_function(L, TOLUA_CAST "get_resource", tolua_region_get_resource);
|
||||
tolua_function(L, TOLUA_CAST "set_resource", tolua_region_set_resource);
|
||||
|
|
|
@ -843,6 +843,16 @@ static int tolua_unit_set_race(lua_State* L)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
tolua_unit_destroy(lua_State* L)
|
||||
{
|
||||
unit * self = (unit *)tolua_tousertype(L, 1, 0);
|
||||
if (self) {
|
||||
remove_unit(&self->region->units, self);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
tolua_unit_create(lua_State* L)
|
||||
{
|
||||
|
@ -927,6 +937,7 @@ tolua_unit_open(lua_State * L)
|
|||
{
|
||||
tolua_function(L, TOLUA_CAST "__tostring", &tolua_unit_tostring);
|
||||
tolua_function(L, TOLUA_CAST "create", &tolua_unit_create);
|
||||
tolua_function(L, TOLUA_CAST "destroy", &tolua_unit_destroy);
|
||||
|
||||
tolua_variable(L, TOLUA_CAST "name", &tolua_unit_get_name, tolua_unit_set_name);
|
||||
tolua_variable(L, TOLUA_CAST "faction", &tolua_unit_get_faction, tolua_unit_set_faction);
|
||||
|
|
|
@ -363,11 +363,11 @@ tolua_get_nmrs(lua_State * L)
|
|||
{
|
||||
int result = -1;
|
||||
int n = (int)tolua_tonumber(L, 1, 0);
|
||||
if (n<=NMRTimeout()) {
|
||||
if (n>=0 && n<=NMRTimeout()) {
|
||||
if (nmrs==NULL) {
|
||||
update_nmrs();
|
||||
result = nmrs[n];
|
||||
}
|
||||
result = nmrs[n];
|
||||
}
|
||||
tolua_pushnumber(L, (lua_Number)result);
|
||||
return 1;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
function multi(f)
|
||||
function mark_multi(f)
|
||||
f.password = "doppelspieler"
|
||||
f.email = "doppelspieler@eressea.de"
|
||||
f.banner = "Diese Partei steht wegen vermuteten Doppelspiels unter Beobachtung."
|
||||
|
|
|
@ -1,18 +1,52 @@
|
|||
-- the locales that this gameworld supports.
|
||||
local locales = { "de", "en" }
|
||||
local multis = {
|
||||
local confirmed_multis = {
|
||||
"agve", "dbgi", "7jfa", "qbki",
|
||||
"gu8y", "wgxe", "iwp0", "r8vz",
|
||||
"78xt", "34fu", "z33r", "fLkr",
|
||||
"yuok"
|
||||
}
|
||||
local suspected_multis = {
|
||||
}
|
||||
|
||||
function kill_multis()
|
||||
-- destroy a faction and all of its buildings.
|
||||
-- destroy the home region, too
|
||||
function kill_faction(f)
|
||||
for u in f.units do
|
||||
if u.building~=nil then
|
||||
building.destroy(u.building)
|
||||
u.region.terrain = "firewall"
|
||||
u.region.terrain_name = nil
|
||||
end
|
||||
unit.destroy(u)
|
||||
end
|
||||
faction.destroy(f)
|
||||
end
|
||||
|
||||
function kill_nonstarters()
|
||||
for f in factions() do
|
||||
if f.lastturn==1 then
|
||||
print(f, f.lastturn)
|
||||
kill_faction(f)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function kill_multis(multis)
|
||||
for idx, fno in ipairs(multis) do
|
||||
local f = get_faction(fno)
|
||||
if f~=nil and f.email=="doppelspieler@eressea.de" then
|
||||
kill_faction(f)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function mark_multis(multis)
|
||||
if multi~=nil and multis~=nil then
|
||||
for idx, fno in ipairs(multis) do
|
||||
local f = get_faction(fno)
|
||||
if f~=nil and f.email~="doppelspieler@eressea.de" then
|
||||
multi(f)
|
||||
mark_multi(f)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -52,6 +86,35 @@ function load_scripts()
|
|||
end
|
||||
end
|
||||
|
||||
function best_scores(n)
|
||||
local f, numf, top
|
||||
|
||||
numf = 0
|
||||
top = { }
|
||||
for f in factions() do
|
||||
numf = numf + 1
|
||||
local r = 0
|
||||
local score = f.score
|
||||
for i = 1,n do
|
||||
if top[i]==nil then
|
||||
top[i] = f
|
||||
break
|
||||
end
|
||||
if top[i].score<score then
|
||||
for j = n,i+1,-1 do
|
||||
top[j]=top[j-1]
|
||||
end
|
||||
top[i] = f
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
return top
|
||||
end
|
||||
|
||||
function write_statistics()
|
||||
end
|
||||
|
||||
function process(orders)
|
||||
-- initialize starting equipment for new players
|
||||
|
||||
|
@ -70,12 +133,15 @@ function process(orders)
|
|||
return -1
|
||||
end
|
||||
|
||||
kill_nonstarters()
|
||||
kill_multis(confirmed_multis)
|
||||
plan_monsters()
|
||||
|
||||
local nmrs = get_nmrs(1)
|
||||
if nmrs >= 80 then
|
||||
print("Shit. More than 80 factions with 1 NMR (" .. nmrs .. ")")
|
||||
write_summary()
|
||||
write_game("aborted.dat")
|
||||
return -1
|
||||
end
|
||||
print (nmrs .. " Factions with 1 NMR")
|
||||
|
@ -88,7 +154,7 @@ function process(orders)
|
|||
-- spawn_braineaters(0.25)
|
||||
-- spawn_ents()
|
||||
|
||||
kill_multis()
|
||||
mark_multis(suspected_multis)
|
||||
-- post-turn updates:
|
||||
update_guards()
|
||||
update_scores()
|
||||
|
@ -99,6 +165,7 @@ function process(orders)
|
|||
-- autoseed(basepath .. "/newfactions", false)
|
||||
|
||||
write_files(locales)
|
||||
write_statistics()
|
||||
|
||||
file = "" .. get_turn() .. ".dat"
|
||||
if write_game(file, "binary")~=0 then
|
||||
|
|
Loading…
Reference in a new issue