(svn r3726) - [6/6] Finalize conversion, finally save the patches struct.

- Remove the temporary synchronisation in during the map-transfer as this is no longer needed
- The saved patches work just like the saved gameoptions. You have a _patches and a _patches_newgame struct. The _patches_newgame struct contains the values from the configuration file and thus the defaults for new games. When a new game is started or an older game is loaded, the default values are copied over to _patches to be used. When you load a game that has PATS saved, the default values are also loaded, but immediately overwritten by the values from the savegame. This ensures that player-based values are always taken from your personal preferences.
- The current implementation also changes the default values if you change player-based settings in the game. For example changing window_snap_radius in a certain game will also change it for all next OpenTTD sessions.
- The savegame version has been increased to 22.
- The last 6 orso patches close the following reports:
  [ 1366446 ] different names for patches: all patch settings have the same name as in the configuration file and are reachable from the console.
  [ 1288024 ] Strange string on OTTD initial screen: configuration (and this includes patches) inputs are validated and clamped to their minimum/maximum values.
  [ 1423198 ] Make "Signals on Drive side" player, not server, based: this is only visual so current setting is to save it with the savegame but not synchronise in multiplayer.
  [ 1208070 ] Patches and New GRF options saved: apart from newgrf this is done
This commit is contained in:
Darkvater
2006-03-02 02:22:15 +00:00
parent bf1bf1e1ec
commit 42dec88a29
9 changed files with 49 additions and 95 deletions

View File

@@ -16,7 +16,6 @@
#include "command.h"
#include "gfx.h"
#include "window.h"
#include "settings.h"
#include "console.h"
#include "variables.h"
#include "ai/ai.h"
@@ -32,8 +31,6 @@ extern const char _openttd_revision[];
static uint32 last_ack_frame;
static void NetworkRecvPatchSettings(NetworkClientState* cs, Packet* p);
// **********
// Sending functions
// DEF_CLIENT_SEND_COMMAND has no parameters
@@ -504,10 +501,6 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_MAP)
InvalidateWindow(WC_NETWORK_STATUS_WINDOW, 0);
}
if (maptype == MAP_PACKET_PATCH) {
NetworkRecvPatchSettings(MY_CLIENT, p);
}
// Check if this was the last packet
if (maptype == MAP_PACKET_END) {
fclose(file_pointer);
@@ -826,37 +819,6 @@ static NetworkClientPacket* const _network_client_packet[] = {
// If this fails, check the array above with network_data.h
assert_compile(lengthof(_network_client_packet) == PACKET_END);
extern const SettingDesc _patch_settings[];
// This is a TEMPORARY solution to get the patch-settings
// to the client. When the patch-settings are saved in the savegame
// this should be removed!!
static void NetworkRecvPatchSettings(NetworkClientState* cs, Packet* p)
{
const SettingDesc *item;
item = _patch_settings;
for (; item->save.cmd != SL_END; item++) {
void *var = ini_get_variable(&item->save, &_patches);
switch (GetVarMemType(item->save.conv)) {
case SLE_VAR_BL:
case SLE_VAR_I8:
case SLE_VAR_U8:
*(uint8 *)(var) = NetworkRecv_uint8(cs, p);
break;
case SLE_VAR_I16:
case SLE_VAR_U16:
*(uint16 *)(var) = NetworkRecv_uint16(cs, p);
break;
case SLE_VAR_I32:
case SLE_VAR_U32:
*(uint32 *)(var) = NetworkRecv_uint32(cs, p);
break;
}
}
}
// Is called after a client is connected to the server
void NetworkClient_Connected(void)
{