summaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-06-17 15:48:57 +0000
committerrubidium <rubidium@openttd.org>2007-06-17 15:48:57 +0000
commit347c28b71ac754aee20f8eeeae1df1a3b9a49d10 (patch)
tree8bc2a050b44170ed785af66e6e9045d429c789db /src/network
parent5fdde681c2aff0976eef8cea59422332527b3a65 (diff)
downloadopenttd-347c28b71ac754aee20f8eeeae1df1a3b9a49d10.tar.xz
(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.
Diffstat (limited to 'src/network')
-rw-r--r--src/network/network_client.cpp11
-rw-r--r--src/network/network_server.cpp8
2 files changed, 8 insertions, 11 deletions
diff --git a/src/network/network_client.cpp b/src/network/network_client.cpp
index 1bfaa0402..d7865beef 100644
--- a/src/network/network_client.cpp
+++ b/src/network/network_client.cpp
@@ -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;
diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp
index 736fe64a1..635148b62 100644
--- a/src/network/network_server.cpp
+++ b/src/network/network_server.cpp
@@ -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?");