forked from github/server
fixing new GIVE
This commit is contained in:
parent
51489e305b
commit
3bd0883298
|
@ -1124,7 +1124,7 @@ cr_region_header(FILE * F, int plid, int nx, int ny, unsigned int uid)
|
|||
} else {
|
||||
fprintf(F, "REGION %d %d %d\n", nx, ny, plid);
|
||||
}
|
||||
fprintf(F, "%d;id\n", uid);
|
||||
if (uid) fprintf(F, "%d;id\n", uid);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1136,6 +1136,11 @@ cr_output_region(FILE * F, report_context * ctx, seen_region * sr)
|
|||
int plid = plane_id(pl), nx, ny;
|
||||
const char * tname;
|
||||
int oc[4][2], o = 0;
|
||||
int uid = r->uid;
|
||||
|
||||
if (sr->mode<=see_neighbour && !r->land) {
|
||||
uid = 0;
|
||||
}
|
||||
|
||||
if (opt_cr_absolute_coords) {
|
||||
nx = r->x;
|
||||
|
@ -1165,11 +1170,11 @@ cr_output_region(FILE * F, report_context * ctx, seen_region * sr)
|
|||
}
|
||||
}
|
||||
while (o--) {
|
||||
cr_region_header(F, plid, oc[o][0], oc[o][1], r->uid);
|
||||
cr_region_header(F, plid, oc[o][0], oc[o][1], uid);
|
||||
fputs("\"wrap\";visibility\n", F);
|
||||
}
|
||||
|
||||
cr_region_header(F, plid, nx, ny, r->uid);
|
||||
cr_region_header(F, plid, nx, ny, uid);
|
||||
|
||||
if (r->land) {
|
||||
const char * str = rname(r, f->locale);
|
||||
|
|
|
@ -139,20 +139,21 @@ give_item(int want, const item_type * itype, unit * src, unit * dest, struct ord
|
|||
int use = use_pooled(src, item2resource(itype), GET_SLACK, n);
|
||||
if (use<n) use += use_pooled(src, item2resource(itype), GET_RESERVE|GET_POOLED_SLACK, n-use);
|
||||
if (dest) {
|
||||
i_change(&dest->items, itype, n);
|
||||
int q = give_quota(src, dest, itype, n);
|
||||
i_change(&dest->items, itype, q);
|
||||
#ifdef RESERVE_GIVE
|
||||
#ifdef RESERVE_DONATIONS
|
||||
change_reservation(dest, item2resource(itype), n);
|
||||
change_reservation(dest, item2resource(itype), q);
|
||||
#else
|
||||
if (src->faction==dest->faction) {
|
||||
change_reservation(dest, item2resource(itype), n);
|
||||
change_reservation(dest, item2resource(itype), q);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#if MUSEUM_MODULE && defined(TODO)
|
||||
/* TODO: use a trigger for the museum warden! */
|
||||
if (a_find(dest->attribs, &at_warden)) {
|
||||
warden_add_give(src, dest, itype, n);
|
||||
warden_add_give(src, dest, itype, q);
|
||||
}
|
||||
#endif
|
||||
handle_event(dest->attribs, "receive", src);
|
||||
|
|
|
@ -727,13 +727,25 @@ end
|
|||
function test_give()
|
||||
free_game()
|
||||
local u1, u2 = two_units(region.create(0, 0, "plain"), two_factions())
|
||||
u1:clear_orders()
|
||||
u1.faction.age = 10
|
||||
u2.faction.age = 10
|
||||
u1:add_item("money", 500)
|
||||
local m1, m2 = u1:get_item("money"), u2:get_item("money")
|
||||
u1:add_order("GIB " .. itoa36(u2.no) .. " 332 Silber")
|
||||
u1:clear_orders()
|
||||
u1:add_order("GIB " .. itoa36(u2.id) .. " 332 Silber")
|
||||
u2:clear_orders()
|
||||
u2:add_order("LERNEN Hiebwaffen")
|
||||
process_orders()
|
||||
assert(u1:get_item("money")==m1-10*u1.number)
|
||||
assert(u2:get_item("money")==m2-10*u2.number)
|
||||
|
||||
m1, m2 = u1:get_item("money"), u2:get_item("money")
|
||||
u1:clear_orders()
|
||||
u1:add_order("GIB " .. itoa36(u2.id) .. " 332 Silber")
|
||||
u2:clear_orders()
|
||||
u2:add_order("HELFE " .. itoa36(u1.faction.id) .. " GIB")
|
||||
process_orders()
|
||||
assert(u1:get_item("money")==m1-332-10*u1.number)
|
||||
print(u2:get_item("money"), m2)
|
||||
assert(u2:get_item("money")==m2+110-10*u2.number)
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue