Move realms from the nation file into a new realms file:
(boundstr, realmstr): Rename, new members ef_type, r_cnum, r_uid, r_realm, r_timestamp. (natstr): Remove member nat_b[]. (EF_REALM, realm_ca): New. (empfile): Add it. (ef_open_srv, ef_close_srv, main): Deal with new file. (getrealm, putrealm): New. (add, new, real, list_realm, sarg_getrange): Use them.
This commit is contained in:
parent
04a8b84592
commit
45adbdb00e
11 changed files with 94 additions and 34 deletions
|
@ -66,6 +66,8 @@ add(void)
|
|||
int stat;
|
||||
struct nstr_item ni;
|
||||
struct lndstr land;
|
||||
struct realmstr realm;
|
||||
time_t current_time = time(NULL);
|
||||
|
||||
for (freecn = 0; NULL != (natp = getnatp(freecn)); freecn++) {
|
||||
if (natp->nat_stat == STAT_UNUSED)
|
||||
|
@ -202,7 +204,12 @@ add(void)
|
|||
natp->nat_xorg = 0;
|
||||
natp->nat_dayno = 0;
|
||||
natp->nat_minused = 0;
|
||||
memset(natp->nat_b, 0, sizeof(natp->nat_b));
|
||||
for (i = 0; i < MAXNOR; i++) {
|
||||
getrealm(i, coun, &realm);
|
||||
realm.r_xl = realm.r_xh = realm.r_yl = realm.r_yh = 0;
|
||||
realm.r_timestamp = current_time;
|
||||
putrealm(&realm);
|
||||
}
|
||||
natp->nat_last_login = natp->nat_last_login = 0;
|
||||
natp->nat_money = 0;
|
||||
natp->nat_level[NAT_TLEV] = start_technology;
|
||||
|
|
|
@ -60,13 +60,14 @@ new(void)
|
|||
{
|
||||
struct sctstr sect;
|
||||
struct natstr *natp;
|
||||
struct boundstr newrealms;
|
||||
struct realmstr newrealm;
|
||||
struct range absrealm;
|
||||
natid num;
|
||||
coord x, y;
|
||||
int i;
|
||||
char *p;
|
||||
char buf[1024];
|
||||
time_t current_time = time(NULL);
|
||||
|
||||
natp = getnatp(player->cnum);
|
||||
if (natp->nat_xorg != 0 || natp->nat_yorg != 0) {
|
||||
|
@ -182,10 +183,15 @@ new(void)
|
|||
natp->nat_xorg = x;
|
||||
natp->nat_yorg = y;
|
||||
xyabsrange(natp, &defrealm, &absrealm);
|
||||
newrealms.b_xl = absrealm.lx;
|
||||
newrealms.b_xh = absrealm.hx;
|
||||
newrealms.b_yl = absrealm.ly;
|
||||
newrealms.b_yh = absrealm.hy;
|
||||
for (i = 0; i < MAXNOR; i++) {
|
||||
getrealm(i, num, &newrealm);
|
||||
newrealm.r_xl = absrealm.lx;
|
||||
newrealm.r_xh = absrealm.hx;
|
||||
newrealm.r_yl = absrealm.ly;
|
||||
newrealm.r_yh = absrealm.hy;
|
||||
newrealm.r_timestamp = current_time;
|
||||
putrealm(&newrealm);
|
||||
}
|
||||
if (players_at_00) {
|
||||
natp->nat_xorg = 0;
|
||||
natp->nat_yorg = 0;
|
||||
|
@ -195,8 +201,6 @@ new(void)
|
|||
natp->nat_level[NAT_RLEV] = start_research;
|
||||
natp->nat_level[NAT_TLEV] = start_technology;
|
||||
natp->nat_level[NAT_ELEV] = start_education;
|
||||
for (i = 0; i < MAXNOR; i++)
|
||||
natp->nat_b[i] = newrealms;
|
||||
natp->nat_tgms = 0;
|
||||
(void)close(open(mailbox(buf, num), O_RDWR | O_TRUNC | O_CREAT, 0660));
|
||||
putnat(natp);
|
||||
|
|
|
@ -42,19 +42,19 @@
|
|||
#include "commands.h"
|
||||
|
||||
static void
|
||||
list_realm(int curr, struct natstr *natp)
|
||||
list_realm(natid curr, struct natstr *natp)
|
||||
{
|
||||
struct boundstr *b;
|
||||
struct realmstr realm;
|
||||
struct range abs;
|
||||
struct range rel;
|
||||
|
||||
abs.width = 0;
|
||||
abs.height = 0;
|
||||
b = &natp->nat_b[curr];
|
||||
abs.lx = b->b_xl;
|
||||
abs.hx = b->b_xh;
|
||||
abs.ly = b->b_yl;
|
||||
abs.hy = b->b_yh;
|
||||
getrealm(curr, natp->nat_cnum, &realm);
|
||||
abs.lx = realm.r_xl;
|
||||
abs.hx = realm.r_xh;
|
||||
abs.ly = realm.r_yl;
|
||||
abs.hy = realm.r_yh;
|
||||
xyrelrange(natp, &abs, &rel);
|
||||
pr("Realm #%d is %d:%d,%d:%d\n", curr, rel.lx, rel.hx, rel.ly, rel.hy);
|
||||
|
||||
|
@ -63,7 +63,7 @@ list_realm(int curr, struct natstr *natp)
|
|||
int
|
||||
real(void)
|
||||
{
|
||||
register struct boundstr *rp;
|
||||
struct realmstr realm;
|
||||
struct natstr *natp;
|
||||
int curr;
|
||||
int lastr;
|
||||
|
@ -97,14 +97,14 @@ real(void)
|
|||
abs.height = 0;
|
||||
if (!sarg_area(player->argp[2], &abs))
|
||||
return RET_SYN;
|
||||
rp = &natp->nat_b[curr];
|
||||
rp->b_xl = abs.lx;
|
||||
rp->b_xh = abs.hx - 1;
|
||||
rp->b_yl = abs.ly;
|
||||
rp->b_yh = abs.hy - 1;
|
||||
natp->nat_b[curr] = *rp;
|
||||
getrealm(curr, natp->nat_cnum, &realm);
|
||||
realm.r_xl = abs.lx;
|
||||
realm.r_xh = abs.hx - 1;
|
||||
realm.r_yl = abs.ly;
|
||||
realm.r_yh = abs.hy - 1;
|
||||
list_realm(curr, natp);
|
||||
putnat(natp);
|
||||
realm.r_timestamp = time(NULL);
|
||||
putrealm(&realm);
|
||||
}
|
||||
return RET_OK;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue