mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r2393) - Implemented threaded saving for OS/2
- Fixed discrepancy with SlArray declaration
This commit is contained in:
parent
6b7f3da7c6
commit
5f652e632b
55
os2.c
55
os2.c
|
@ -9,6 +9,8 @@
|
|||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <process.h>
|
||||
#include <time.h>
|
||||
#include <dos.h>
|
||||
|
||||
|
@ -24,11 +26,6 @@
|
|||
#include <SDL.h>
|
||||
#endif
|
||||
|
||||
static inline int strcasecmp(const char* s1, const char* s2)
|
||||
{
|
||||
return stricmp(s1, s2);
|
||||
}
|
||||
|
||||
static char *_fios_path;
|
||||
static char *_fios_save_path;
|
||||
static char *_fios_scn_path;
|
||||
|
@ -53,7 +50,7 @@ int compare_FiosItems(const void *a, const void *b)
|
|||
if (_savegame_sort_order < 2) // sort by date
|
||||
r = da->mtime < db->mtime ? -1 : 1;
|
||||
else
|
||||
r = strcasecmp(
|
||||
r = stricmp(
|
||||
da->title[0] != '\0' ? da->title : da->name,
|
||||
db->title[0] != '\0' ? db->title : db->name
|
||||
);
|
||||
|
@ -153,7 +150,7 @@ FiosItem *FiosGetSavegameList(int *num, int mode)
|
|||
if (stat(filename, &sb) || S_ISDIR(sb.st_mode)) continue;
|
||||
|
||||
t = strrchr(dirent->d_name, '.');
|
||||
if (t != NULL && strcasecmp(t, ".sav") == 0) { // OpenTTD
|
||||
if (t != NULL && stricmp(t, ".sav") == 0) { // OpenTTD
|
||||
fios = FiosAlloc();
|
||||
fios->type = FIOS_TYPE_FILE;
|
||||
fios->mtime = sb.st_mtime;
|
||||
|
@ -161,9 +158,9 @@ FiosItem *FiosGetSavegameList(int *num, int mode)
|
|||
ttd_strlcpy(fios->name, dirent->d_name, lengthof(fios->name));
|
||||
} else if (mode == SLD_LOAD_GAME || mode == SLD_LOAD_SCENARIO) {
|
||||
if (t != NULL && (
|
||||
strcasecmp(t, ".ss1") == 0 ||
|
||||
strcasecmp(t, ".sv1") == 0 ||
|
||||
strcasecmp(t, ".sv2") == 0
|
||||
stricmp(t, ".ss1") == 0 ||
|
||||
stricmp(t, ".sv1") == 0 ||
|
||||
stricmp(t, ".sv2") == 0
|
||||
)) { // TTDLX(Patch)
|
||||
fios = FiosAlloc();
|
||||
fios->type = FIOS_TYPE_OLDFILE;
|
||||
|
@ -273,7 +270,7 @@ FiosItem *FiosGetScenarioList(int *num, int mode)
|
|||
if (stat(filename, &sb) || S_ISDIR(sb.st_mode)) continue;
|
||||
|
||||
t = strrchr(dirent->d_name, '.');
|
||||
if (t != NULL && strcasecmp(t, ".scn") == 0) { // OpenTTD
|
||||
if (t != NULL && stricmp(t, ".scn") == 0) { // OpenTTD
|
||||
fios = FiosAlloc();
|
||||
fios->type = FIOS_TYPE_SCENARIO;
|
||||
fios->mtime = sb.st_mtime;
|
||||
|
@ -282,8 +279,8 @@ FiosItem *FiosGetScenarioList(int *num, int mode)
|
|||
} else if (mode == SLD_LOAD_GAME || mode == SLD_LOAD_SCENARIO ||
|
||||
mode == SLD_NEW_GAME) {
|
||||
if (t != NULL && (
|
||||
strcasecmp(t, ".sv0") == 0 ||
|
||||
strcasecmp(t, ".ss0") == 0
|
||||
stricmp(t, ".sv0") == 0 ||
|
||||
stricmp(t, ".ss0") == 0
|
||||
)) { // TTDLX(Patch)
|
||||
fios = FiosAlloc();
|
||||
fios->type = FIOS_TYPE_OLD_SCENARIO;
|
||||
|
@ -410,7 +407,7 @@ void FiosMakeSavegameName(char *buf, const char *name)
|
|||
|
||||
// Don't append the extension, if it is already there
|
||||
period = strrchr(name, '.');
|
||||
if (period != NULL && strcasecmp(period, extension) == 0) extension = "";
|
||||
if (period != NULL && stricmp(period, extension) == 0) extension = "";
|
||||
|
||||
sprintf(buf, "%s\\%s%s", _fios_path, name, extension);
|
||||
}
|
||||
|
@ -713,3 +710,33 @@ bool InsertTextBufferClipboard(Textbuf *tb)
|
|||
// TODO
|
||||
return false;
|
||||
}
|
||||
|
||||
static TID thread1 = 0;
|
||||
|
||||
// The thread function must be declared and compiled using _Optlink linkage, apparently
|
||||
// It seems to work, though :)
|
||||
|
||||
bool CreateOTTDThread(void *func, void *param)
|
||||
{
|
||||
thread1 = _beginthread(func, NULL, 32768, param);
|
||||
fprintf(stderr, "beginthread returns: %d\n", thread1); //
|
||||
|
||||
if (thread1 == -1)
|
||||
return(false);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
void CloseOTTDThread(void)
|
||||
{
|
||||
_endthread();
|
||||
return;
|
||||
}
|
||||
|
||||
void JoinOTTDThread(void)
|
||||
{
|
||||
if (thread1 == 0)
|
||||
return;
|
||||
|
||||
DosWaitThread(&thread1, DCWW_WAIT);
|
||||
}
|
||||
|
|
|
@ -188,7 +188,7 @@ struct SaveLoad {
|
|||
|
||||
void SlSetArrayIndex(uint index);
|
||||
int SlIterateArray(void);
|
||||
void SlArray(void *array, uint length, uint conv);
|
||||
void SlArray(void *array, uint length, VarType conv);
|
||||
void SlObject(void *object, const SaveLoad *desc);
|
||||
void SlAutolength(AutolengthProc *proc, void *arg);
|
||||
uint SlGetFieldLength(void);
|
||||
|
|
Loading…
Reference in New Issue