On load, use previous local company or first usable company
Instead of always using the first company slot
This commit is contained in:
@@ -970,9 +970,8 @@ bool AfterLoadGame()
|
||||
* a company does not exist yet. So create one here.
|
||||
* 1 exception: network-games. Those can have 0 companies
|
||||
* But this exception is not true for non-dedicated network servers! */
|
||||
if (!Company::IsValidID(COMPANY_FIRST) && (!_networking || (_networking && _network_server && !_network_dedicated))) {
|
||||
DoStartupNewCompany(false);
|
||||
Company *c = Company::Get(COMPANY_FIRST);
|
||||
if (!Company::IsValidID(GetDefaultLocalCompany()) && (!_networking || (_networking && _network_server && !_network_dedicated))) {
|
||||
Company *c = DoStartupNewCompany(false);
|
||||
c->settings = _settings_client.company;
|
||||
}
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
#include "../map_func.h"
|
||||
#include "../rev.h"
|
||||
#include "../strings_func.h"
|
||||
#include "../company_func.h"
|
||||
#include "table/strings.h"
|
||||
|
||||
#include <vector>
|
||||
@@ -62,6 +63,8 @@ static const uint32 _sl_xv_slxi_chunk_version = 0; ///< current version
|
||||
|
||||
static void loadVL(const SlxiSubChunkInfo *info, uint32 length);
|
||||
static uint32 saveVL(const SlxiSubChunkInfo *info, bool dry_run);
|
||||
static void loadLC(const SlxiSubChunkInfo *info, uint32 length);
|
||||
static uint32 saveLC(const SlxiSubChunkInfo *info, bool dry_run);
|
||||
|
||||
const SlxiSubChunkInfo _sl_xv_sub_chunk_infos[] = {
|
||||
{ XSLFI_VERSION_LABEL, XSCF_IGNORABLE_ALL, 1, 1, "version_label", saveVL, loadVL, nullptr },
|
||||
@@ -129,6 +132,7 @@ const SlxiSubChunkInfo _sl_xv_sub_chunk_infos[] = {
|
||||
{ XSLFI_TOWN_MULTI_BUILDING, XSCF_NULL, 1, 1, "town_multi_building", nullptr, nullptr, nullptr },
|
||||
{ XSLFI_SHIP_LOST_COUNTER, XSCF_NULL, 1, 1, "ship_lost_counter", nullptr, nullptr, nullptr },
|
||||
{ XSLFI_BUILD_OBJECT_RATE_LIMIT,XSCF_NULL, 1, 1, "build_object_rate_limit", nullptr, nullptr, nullptr },
|
||||
{ XSLFI_LOCAL_COMPANY, XSCF_IGNORABLE_ALL, 1, 1, "local_company", saveLC, loadLC, nullptr },
|
||||
{ XSLFI_NULL, XSCF_NULL, 0, 0, nullptr, nullptr, nullptr, nullptr },// This is the end marker
|
||||
};
|
||||
|
||||
@@ -627,6 +631,22 @@ static uint32 saveVL(const SlxiSubChunkInfo *info, bool dry_run)
|
||||
return length;
|
||||
}
|
||||
|
||||
static void loadLC(const SlxiSubChunkInfo *info, uint32 length)
|
||||
{
|
||||
if (length == 1) {
|
||||
_loaded_local_company = (CompanyID) ReadBuffer::GetCurrent()->ReadByte();
|
||||
} else {
|
||||
DEBUG(sl, 1, "SLXI chunk: feature: '%s', version: %d, has data of wrong length: %u", info->name, _sl_xv_feature_versions[info->index], length);
|
||||
ReadBuffer::GetCurrent()->SkipBytes(length);
|
||||
}
|
||||
}
|
||||
|
||||
static uint32 saveLC(const SlxiSubChunkInfo *info, bool dry_run)
|
||||
{
|
||||
if (!dry_run) MemoryDumper::GetCurrent()->WriteByte(_local_company);
|
||||
return 1;
|
||||
}
|
||||
|
||||
extern const ChunkHandler _version_ext_chunk_handlers[] = {
|
||||
{ 'SLXI', Save_SLXI, Load_SLXI, nullptr, Load_SLXI, CH_RIFF | CH_LAST},
|
||||
};
|
||||
|
||||
@@ -86,6 +86,7 @@ enum SlXvFeatureIndex {
|
||||
XSLFI_TOWN_MULTI_BUILDING, ///< Allow multiple stadium/church buildings in a single town
|
||||
XSLFI_SHIP_LOST_COUNTER, ///< Ship lost counter
|
||||
XSLFI_BUILD_OBJECT_RATE_LIMIT, ///< Build object rate limit
|
||||
XSLFI_LOCAL_COMPANY, ///< Local company ID
|
||||
|
||||
XSLFI_RIFF_HEADER_60_BIT, ///< Size field in RIFF chunk header is 60 bit
|
||||
XSLFI_HEIGHT_8_BIT, ///< Map tile height is 8 bit instead of 4 bit, but savegame version may be before this became true in trunk
|
||||
|
||||
Reference in New Issue
Block a user