contact: Initialize contact state properly
A country must always be in contact of itself when option HIDDEN is enabled. The code ensures this by establishing contact whenever a player logs in, in init_nats(). This is not the proper place. Game state should be initialized in empfile's oninit() callback, in this case nat_oninit(). Do that, and drop the putcontact() from init_nats(). Note that option LOSE_CONTACT only affects contact to other countries: agecontact() doesn't age the country's contact to itself. Use the opportunity to initialize contact so that getcontact() works even when HIDDEN is disabled. Just cleanup, it isn't actually called then. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
parent
ae011d089b
commit
cf4e9bc89d
15 changed files with 83 additions and 80 deletions
|
@ -34,6 +34,7 @@
|
|||
|
||||
#include <assert.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include "commodity.h"
|
||||
#include "game.h"
|
||||
#include "land.h"
|
||||
|
@ -317,6 +318,11 @@ nat_oninit(void *ptr)
|
|||
struct natstr *np = ptr;
|
||||
|
||||
np->nat_cnum = np->nat_uid;
|
||||
|
||||
if (opt_HIDDEN)
|
||||
np->nat_contact[np->nat_cnum] = 1;
|
||||
else
|
||||
memset(np->nat_contact, 1, sizeof(np->nat_contact));
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
* Known contributors to this file:
|
||||
* Dave Pare, 1994
|
||||
* Steve McClure, 2000
|
||||
* Markus Armbruster, 2007-2014
|
||||
* Markus Armbruster, 2007-2016
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
@ -53,9 +53,6 @@ init_nats(void)
|
|||
player->map = ef_ptr(EF_MAP, player->cnum);
|
||||
player->bmap = ef_ptr(EF_BMAP, player->cnum);
|
||||
|
||||
if (opt_HIDDEN)
|
||||
putcontact(np, player->cnum, FOUND_SPY);
|
||||
|
||||
player_set_nstat(player, np);
|
||||
grant_btus(np, game_tick_to_now(&np->nat_access));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue