forked from github/server
economy reorganization
more gentle magic school parsing null banners fix: building taxes
This commit is contained in:
parent
3e2da75843
commit
a2475ebdc0
10 changed files with 200 additions and 196 deletions
|
@ -977,7 +977,7 @@ cr_find_address(FILE * F, const faction * uf, const faction_list * addresses)
|
|||
fprintf(F, "PARTEI %d\n", f->no);
|
||||
fprintf(F, "\"%s\";Parteiname\n", f->name);
|
||||
if (f->email) fprintf(F, "\"%s\";email\n", f->email);
|
||||
fprintf(F, "\"%s\";banner\n", f->banner);
|
||||
if (f->banner) fprintf(F, "\"%s\";banner\n", f->banner);
|
||||
fprintf(F, "\"%s\";locale\n", locale_name(f->locale));
|
||||
if (f->alliance!=NULL && f->alliance==uf->alliance) {
|
||||
fprintf(F, "%d;alliance\n", f->alliance->id);
|
||||
|
@ -1412,7 +1412,7 @@ report_computer(const char * filename, report_context * ctx, const char * charse
|
|||
|
||||
fprintf(F, "\"%s\";Parteiname\n", f->name);
|
||||
fprintf(F, "\"%s\";email\n", f->email);
|
||||
fprintf(F, "\"%s\";banner\n", f->banner);
|
||||
if (f->banner) fprintf(F, "\"%s\";banner\n", f->banner);
|
||||
print_items(F, f->items, f->locale);
|
||||
fputs("OPTIONEN\n", F);
|
||||
for (i=0;i!=MAXOPTIONS;++i) {
|
||||
|
|
|
@ -3219,12 +3219,11 @@ peasant_taxes(region * r)
|
|||
|
||||
maxsize = buildingeffsize(b, false);
|
||||
morale = region_get_morale(r);
|
||||
if (maxsize > morale) {
|
||||
if (morale<maxsize) {
|
||||
maxsize = morale;
|
||||
}
|
||||
|
||||
if (maxsize>0) {
|
||||
int taxmoney = (int)((money * maxsize) * b->type->taxes(b));
|
||||
if (maxsize>0 && morale>0) {
|
||||
int taxmoney = (int)(money * b->type->taxes(b, maxsize));
|
||||
if (taxmoney>0) {
|
||||
change_money(u, taxmoney);
|
||||
rsetmoney(r, money - taxmoney);
|
||||
|
@ -3235,15 +3234,16 @@ peasant_taxes(region * r)
|
|||
}
|
||||
|
||||
void
|
||||
produce(void)
|
||||
produce(struct region *r)
|
||||
{
|
||||
request workers[1024];
|
||||
region *r;
|
||||
request *taxorders, *sellorders, *stealorders, *buyorders;
|
||||
unit *u;
|
||||
int todo;
|
||||
int rule_taxation = get_param_int(global.parameters, "rules.economy.taxation", 0);
|
||||
int rule_autowork = get_param_int(global.parameters, "work.auto", 0);
|
||||
static int rule_taxation = -1;
|
||||
static int rule_autowork = -1;
|
||||
boolean limited = true;
|
||||
request * nextworker = workers;
|
||||
|
||||
/* das sind alles befehle, die 30 tage brauchen, und die in thisorder
|
||||
* stehen! von allen 30-tage befehlen wird einfach der letzte verwendet
|
||||
|
@ -3255,9 +3255,10 @@ produce(void)
|
|||
*
|
||||
* lehren vor lernen. */
|
||||
|
||||
for (r = regions; r; r = r->next) {
|
||||
boolean limited = true;
|
||||
request * nextworker = workers;
|
||||
if (rule_taxation<0) {
|
||||
rule_taxation = get_param_int(global.parameters, "rules.economy.taxation", 0);
|
||||
rule_autowork = get_param_int(global.parameters, "work.auto", 0);
|
||||
}
|
||||
|
||||
assert(rmoney(r) >= 0);
|
||||
assert(rpeasants(r) >= 0);
|
||||
|
@ -3392,4 +3393,3 @@ produce(void)
|
|||
assert(rmoney(r) >= 0);
|
||||
assert(rpeasants(r) >= 0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ extern int income(const struct unit * u);
|
|||
#define MAXNEWBIES 5
|
||||
|
||||
void economics(struct region *r);
|
||||
void produce(void);
|
||||
void produce(struct region *r);
|
||||
void auto_work(struct region * r);
|
||||
|
||||
enum { IC_WORK, IC_ENTERTAIN, IC_TAX, IC_TRADE, IC_TRADETAX, IC_STEAL, IC_MAGIC };
|
||||
|
|
|
@ -3962,10 +3962,8 @@ init_processor(void)
|
|||
add_proc_order(p, K_STUDY, &learn_cmd, PROC_THISORDER|PROC_LONGORDER, "Lernen");
|
||||
|
||||
p+=10;
|
||||
|
||||
add_proc_order(p, K_MAKE, &make_cmd, PROC_THISORDER|PROC_LONGORDER, "Produktion");
|
||||
p+=10;
|
||||
add_proc_global(p, &produce, "Arbeiten, Handel, Rekruten");
|
||||
add_proc_postregion(p, &produce, "Arbeiten, Handel, Rekruten");
|
||||
add_proc_postregion(p, &split_allocations, "Produktion II");
|
||||
|
||||
p+=10;
|
||||
|
|
|
@ -1698,7 +1698,7 @@ list_address(FILE * F, const faction * uf, const faction_list * seenfactions)
|
|||
char buf[8192];
|
||||
char label = '-';
|
||||
|
||||
sprintf(buf, "%s: %s; %s", factionname(f), f->email, f->banner);
|
||||
sprintf(buf, "%s: %s; %s", factionname(f), f->email, f->banner?f->banner:"");
|
||||
if (ALLIED(uf, f)) label = '*';
|
||||
else if (alliedfaction(NULL, uf, f, HELP_ALL)) label = '+';
|
||||
rparagraph(F, buf, 4, 0, label);
|
||||
|
|
|
@ -74,8 +74,18 @@ getmagicskill(const struct locale * lang)
|
|||
variant token;
|
||||
const char * s = getstrtoken();
|
||||
|
||||
if (s && s[0]) {
|
||||
if (findtoken(tokens, s, &token)==E_TOK_SUCCESS) {
|
||||
return (magic_t)token.i;
|
||||
} else {
|
||||
char buffer[3];
|
||||
buffer[0] = s[0];
|
||||
buffer[1] = s[1];
|
||||
buffer[2] = '\0';
|
||||
if (findtoken(tokens, buffer, &token)==E_TOK_SUCCESS) {
|
||||
return (magic_t)token.i;
|
||||
}
|
||||
}
|
||||
}
|
||||
return M_NONE;
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ typedef struct building_type {
|
|||
void (*init)(struct building_type*);
|
||||
void (*age)(struct building *);
|
||||
int (*protection)(struct building *, struct unit *);
|
||||
double (*taxes)(struct building *);
|
||||
double (*taxes)(struct building *, int size);
|
||||
struct attrib * attribs;
|
||||
} building_type;
|
||||
|
||||
|
|
|
@ -320,7 +320,7 @@ parse_buildings(xmlDocPtr doc)
|
|||
} else if (strcmp((const char*)propValue, "protection")==0) {
|
||||
btype->protection = (int (*)(struct building*, struct unit *))fun;
|
||||
} else if (strcmp((const char*)propValue, "taxes")==0) {
|
||||
btype->taxes = (double (*)(struct building*))fun;
|
||||
btype->taxes = (double (*)(struct building*, int))fun;
|
||||
} else if (strcmp((const char*)propValue, "age")==0) {
|
||||
btype->age = (void (*)(struct building*))fun;
|
||||
} else {
|
||||
|
|
|
@ -448,9 +448,11 @@ lua_building_taxes(building * b)
|
|||
lua_rawget(L, LUA_GLOBALSINDEX);
|
||||
type=lua_type(L, 1);
|
||||
if (lua_isfunction(L, 1)) {
|
||||
int level = buildingeffsize(b, false);
|
||||
tolua_pushusertype(L, (void *)b, TOLUA_CAST "building");
|
||||
tolua_pushnumber(L, level);
|
||||
|
||||
if (lua_pcall(L, 1, 1, 0)!=0) {
|
||||
if (lua_pcall(L, 2, 1, 0)!=0) {
|
||||
const char* error = lua_tostring(L, -1);
|
||||
log_error(("building_taxes(%s) calling '%s': %s.\n",
|
||||
buildingname(b), fname, error));
|
||||
|
|
|
@ -31,18 +31,12 @@ function building_protection(b, u)
|
|||
return 1
|
||||
end
|
||||
|
||||
function building_taxes(b)
|
||||
function building_taxes(b, blevel)
|
||||
btype = b.type
|
||||
bsize = b.size
|
||||
if btype=="castle" then
|
||||
if bsize>=6250 then return 0.05 end
|
||||
if bsize>=1250 then return 0.04 end
|
||||
if bsize>=250 then return 0.03 end
|
||||
if bsize>=50 then return 0.02 end
|
||||
if bsize>=10 then return 0.01 end
|
||||
return blevel * 0.01
|
||||
elseif btype=="watch" then
|
||||
if bsize>=10 then return 0.01 end
|
||||
if bsize>=5 then return 0.005 end
|
||||
return blevel * 0.005
|
||||
end
|
||||
return 0.0
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue