mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r10277) [0.5] -Backport from trunk (10116, r10128, r10130, r10131, r10137, r10138):
- Feature: console command to get the current game date (r10137) - Fix: When you got a sufficiently small resolution, there is a possibility for a division by zero when a sound is played (r10138) - Fix: When removing a dock, a ship will always try to reach the old location of the dock even when it cannot anymore because it the old location of the dock is now land instead of water [FS#810] (r10131) - Fix: SetCurrentGrfLangID returned the wrong language ids for most languages (r10130)
This commit is contained in:
parent
aa6a621f0a
commit
526b2ae81b
|
@ -928,6 +928,20 @@ DEF_CONSOLE_CMD(ConGetSeed)
|
|||
return true;
|
||||
}
|
||||
|
||||
DEF_CONSOLE_CMD(ConGetDate)
|
||||
{
|
||||
YearMonthDay ymd;
|
||||
if (argc == 0) {
|
||||
IConsoleHelp("Returns the current date (day-month-year) of the game. Usage: 'getdate'");
|
||||
return true;
|
||||
}
|
||||
|
||||
ConvertDateToYMD(_date, &ymd);
|
||||
IConsolePrintF(_icolour_def, "Date: %d-%d-%d", ymd.day, ymd.month + 1, ymd.year);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
DEF_CONSOLE_CMD(ConAlias)
|
||||
{
|
||||
IConsoleAlias *alias;
|
||||
|
@ -1484,6 +1498,7 @@ void IConsoleStdLibRegister(void)
|
|||
IConsoleCmdRegister("newgame", ConNewGame);
|
||||
IConsoleCmdRegister("restart", ConRestart);
|
||||
IConsoleCmdRegister("getseed", ConGetSeed);
|
||||
IConsoleCmdRegister("getdate", ConGetDate);
|
||||
IConsoleCmdRegister("quit", ConExit);
|
||||
IConsoleCmdRegister("resetengines", ConResetEngines);
|
||||
IConsoleCmdRegister("return", ConReturn);
|
||||
|
|
17
fileio.c
17
fileio.c
|
@ -149,3 +149,20 @@ void FioOpenFile(int slot, const char *filename)
|
|||
_fio.handles[slot] = f;
|
||||
FioSeekToFile(slot << 24);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitizes a filename, i.e. removes all illegal characters from it.
|
||||
* @param filename the "\0" terminated filename
|
||||
*/
|
||||
void SanitizeFilename(char *filename)
|
||||
{
|
||||
for (; *filename != '\0'; filename++) {
|
||||
switch (*filename) {
|
||||
/* The following characters are not allowed in filenames
|
||||
* on at least one of the supported operating systems: */
|
||||
case ':': case '\\': case '*': case '?': case '/': case '<': case '>': case '|': case '"':
|
||||
*filename = '_';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
1
fileio.h
1
fileio.h
|
@ -15,5 +15,6 @@ void FioOpenFile(int slot, const char *filename);
|
|||
void FioReadBlock(void *ptr, uint size);
|
||||
void FioSkipBytes(int n);
|
||||
bool FioCheckFileExists(const char *filename);
|
||||
void SanitizeFilename(char *filename);
|
||||
|
||||
#endif /* FILEIO_H */
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "tgp.h"
|
||||
#include "settings.h"
|
||||
#include "date.h"
|
||||
#include "fileio.h"
|
||||
|
||||
#include "fios.h"
|
||||
/* Variables to display file lists */
|
||||
|
@ -1337,6 +1338,7 @@ static void GenerateFileName(void)
|
|||
SetDParam(1, p->name_2);
|
||||
SetDParam(2, _date);
|
||||
GetString(_edit_str_buf, STR_4004, lastof(_edit_str_buf));
|
||||
SanitizeFilename(_edit_str_buf);
|
||||
}
|
||||
|
||||
extern void StartupEngines(void);
|
||||
|
|
1
newgrf.c
1
newgrf.c
|
@ -1626,6 +1626,7 @@ static const SpriteGroup* CreateGroupFromGroupID(byte feature, byte setid, byte
|
|||
|
||||
if (feature != _cur_grffile->spriteset_feature) {
|
||||
grfmsg(GMS_WARN, "NewSpriteGroup(0x%02X:0x%02X): Sprite set feature 0x%02X does not match action feature 0x%02X, skipping.",
|
||||
setid, type,
|
||||
_cur_grffile->spriteset_feature, feature);
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -404,7 +404,7 @@ void SetCurrentGrfLangID(const char *iso_name)
|
|||
for (i=0; i < lengthof(iso_codes); i++) {
|
||||
if (strncmp(iso_codes[i].code, iso_name, strlen(iso_codes[i].code)) == 0) {
|
||||
/* We found a match, so let's use it. */
|
||||
ret = i;
|
||||
ret = iso_codes[i].grfLangID;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "screenshot.h"
|
||||
#include "variables.h"
|
||||
#include "date.h"
|
||||
#include "fileio.h"
|
||||
|
||||
char _screenshot_format_name[8];
|
||||
uint _num_screenshot_formats;
|
||||
|
@ -507,6 +508,7 @@ static char *MakeScreenshotName(const char *ext)
|
|||
GetString(_screenshot_name, STR_4004, lastof(_screenshot_name));
|
||||
}
|
||||
|
||||
SanitizeFilename(_screenshot_name);
|
||||
base = strchr(_screenshot_name, 0);
|
||||
base[0] = '.'; strcpy(base + 1, ext);
|
||||
|
||||
|
|
|
@ -239,7 +239,8 @@ static void ProcessShipOrder(Vehicle *v)
|
|||
|
||||
if (order->type == v->current_order.type &&
|
||||
order->flags == v->current_order.flags &&
|
||||
order->dest == v->current_order.dest)
|
||||
order->dest == v->current_order.dest &&
|
||||
(order->type != OT_GOTO_STATION || GetStation(order->dest)->dock_tile != 0))
|
||||
return;
|
||||
|
||||
v->current_order = *order;
|
||||
|
@ -253,6 +254,8 @@ static void ProcessShipOrder(Vehicle *v)
|
|||
st = GetStation(order->dest);
|
||||
if (st->dock_tile != 0) {
|
||||
v->dest_tile = TILE_ADD(st->dock_tile, ToTileIndexDiff(GetDockOffset(st->dock_tile)));
|
||||
} else {
|
||||
v->cur_order_index++;
|
||||
}
|
||||
} else if (order->type == OT_GOTO_DEPOT) {
|
||||
v->dest_tile = GetDepot(order->dest)->xy;
|
||||
|
|
2
sound.c
2
sound.c
|
@ -208,7 +208,7 @@ static void SndPlayScreenCoordFx(SoundFx sound, int x, int y)
|
|||
|
||||
StartSound(
|
||||
sound,
|
||||
left / (vp->virtual_width / ((PANNING_LEVELS << 1) + 1)) - PANNING_LEVELS,
|
||||
left / max(1, vp->virtual_width / ((PANNING_LEVELS << 1) + 1)) - PANNING_LEVELS,
|
||||
(GetSound(sound)->volume * msf.effect_vol * _vol_factor_by_zoom[vp->zoom]) >> 15
|
||||
);
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue