1
0
mirror of https://github.com/OpenTTD/OpenTTD.git synced 2025-08-19 04:29:09 +00:00

(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.

-Codechange: add support for personal directories on Windows.
-Fix [FS#153, FS#193, FS#502, FS#816, FS#854]: fix issues related to fixed names, fixed places of files/directories and application bundles.
This commit is contained in:
rubidium
2007-06-17 15:48:57 +00:00
parent 5fdde681c2
commit 347c28b71a
25 changed files with 427 additions and 274 deletions

View File

@@ -21,6 +21,7 @@
#include "../variables.h"
#include "../ai/ai.h"
#include "../helpers.hpp"
#include "../fileio.h"
// This file handles all the client-commands
@@ -269,7 +270,7 @@ DEF_CLIENT_SEND_COMMAND_PARAM(PACKET_CLIENT_RCON)(const char *pass, const char *
// DEF_CLIENT_RECEIVE_COMMAND has parameter: Packet *p
// **********
extern bool SafeSaveOrLoad(const char *filename, int mode, int newgm);
extern bool SafeSaveOrLoad(const char *filename, int mode, int newgm, Subdirectory subdir);
DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_FULL)
{
@@ -489,7 +490,6 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_WAIT)
DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_MAP)
{
static char filename[256];
static FILE *file_pointer;
byte maptype;
@@ -500,10 +500,7 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_MAP)
// First packet, init some stuff
if (maptype == MAP_PACKET_START) {
// The name for the temp-map
snprintf(filename, lengthof(filename), "%s%snetwork_client.tmp", _paths.autosave_dir, PATHSEP);
file_pointer = fopen(filename, "wb");
file_pointer = FioFOpenFile("network_client.tmp", "wb", AUTOSAVE_DIR);;
if (file_pointer == NULL) {
_switch_mode_errorstr = STR_NETWORK_ERR_SAVEGAMEERROR;
return NETWORK_RECV_STATUS_SAVEGAME;
@@ -545,7 +542,7 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_MAP)
InvalidateWindow(WC_NETWORK_STATUS_WINDOW, 0);
/* The map is done downloading, load it */
if (!SafeSaveOrLoad(filename, SL_LOAD, GM_NORMAL)) {
if (!SafeSaveOrLoad("network_client.tmp", SL_LOAD, GM_NORMAL, AUTOSAVE_DIR)) {
DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0);
_switch_mode_errorstr = STR_NETWORK_ERR_SAVEGAMEERROR;
return NETWORK_RECV_STATUS_SAVEGAME;

View File

@@ -24,6 +24,7 @@
#include "../variables.h"
#include "../genworld.h"
#include "../helpers.hpp"
#include "../fileio.h"
// This file handles all the server-commands
@@ -307,14 +308,13 @@ DEF_SERVER_SEND_COMMAND(PACKET_SERVER_MAP)
}
if (cs->status == STATUS_AUTH) {
char filename[256];
const char *filename = "network_server.tmp";
Packet *p;
// Make a dump of the current game
snprintf(filename, lengthof(filename), "%s%snetwork_server.tmp", _paths.autosave_dir, PATHSEP);
if (SaveOrLoad(filename, SL_SAVE) != SL_OK) error("network savedump failed");
if (SaveOrLoad(filename, SL_SAVE, AUTOSAVE_DIR) != SL_OK) error("network savedump failed");
file_pointer = fopen(filename, "rb");
file_pointer = FioFOpenFile(filename, "rb", AUTOSAVE_DIR);
fseek(file_pointer, 0, SEEK_END);
if (ftell(file_pointer) == 0) error("network savedump failed - zero sized savegame?");