(svn r17158) [0.7] -Backport from trunk:

- Fix: Some typos in .obg stuff (r17136)
- Fix: Mark industry tiles dirty when trigger are triggered (r17118)
- Fix: Squirrel_export.sh failed for some locales (r17109)
- Fix: Make restart command work again and make the help show how it works and how it does not work [FS#3092] (r17097)
- Fix: Make ParseStringChoice a bit safer (r17095)
- Change: Make strgen warn if the translation uses STRINGn or RAW_STRING instead of STRING (r17137, r17129)
This commit is contained in:
rubidium 2009-08-12 15:22:50 +00:00
parent a61574a033
commit 53983ec1af
14 changed files with 50 additions and 37 deletions

View File

@ -1,7 +1,7 @@
; $Id$
;
; This represents the original graphics as on the Transport
; Tycoon Deluxe for Windows.
; Tycoon Deluxe for Windows CD.
;
[metadata]
name = original_windows

View File

@ -117,7 +117,7 @@
- Add: [NoAI] AIAirport::GetPrice, returning the building cost of an airport (r16252)
- Add: [NoAI] Two new error codes to AITile: ERR_AREA_ALREADY_FLAT and ERR_EXCAVATION_WOULD_DAMAGE (r16171)
- Add: [NoAI] AITile::Get(Min|Max|Corner)Height (r16166)
- Add: [NoAI] Several functions to AIOrder to check the what kind of order an order is [FS#2801] (r16165)
- Add: [NoAI] Several functions to AIOrder to check the what kind of order an order is and AIVehicle.SendVehicleToDepotForServicing [FS#2801] (r16165)
- Add: [NoAI] UseAsRandomAI as function in info.nut. When an AI returns false, it will never be chosen as random AI (r16113)
- Add: [NoAI] AIOF_STOP_IN_DEPOT to the orderflags in AIOrder to allow stop-in-depot orders (r16107)
- Add: [NoAI] GetURL() as possible function to info.nut. If AIs implement it, that url is shown when the AI crashes and also in the AI selection window [FS#2808] (r16093)

View File

@ -26,7 +26,7 @@
[metadata]
; the name of the pack, preferably less than 16 characters
name = example
; the short name (4 characters), used to identify this set within NewGRFs
; the short name (4 characters), used to identify this set
shortname = XMPL
; the version of this graphics set (read as single integer)
version = 0

View File

@ -2,6 +2,10 @@
# $Id$
# Set neutral locale so sort behaves the same everywhere
LC_ALL=C
export LC_ALL
# We really need gawk for this!
AWK=gawk

View File

@ -933,13 +933,16 @@ DEF_CONSOLE_CMD(ConRestart)
if (argc == 0) {
IConsoleHelp("Restart game. Usage: 'restart'");
IConsoleHelp("Restarts a game. It tries to reproduce the exact same map as the game started with.");
IConsoleHelp("However:");
IConsoleHelp(" * restarting games started in another version might create another map due to difference in map generation");
IConsoleHelp(" * restarting games based on scenarios, loaded games or heightmaps will start a new game based on the settings stored in the scenario/savegame");
return true;
}
/* Don't copy the _newgame pointers to the real pointers, so call SwitchToMode directly */
_settings_game.game_creation.map_x = MapLogX();
_settings_game.game_creation.map_y = FindFirstBit(MapSizeY());
SwitchToMode(SM_NEWGAME);
SwitchToMode(SM_RESTARTGAME);
return true;
}

View File

@ -39,7 +39,7 @@ void StartupEconomy();
void StartupCompanies();
void StartupDisasters();
void InitializeGame(uint size_x, uint size_y, bool reset_date);
void InitializeGame(uint size_x, uint size_y, bool reset_date, bool reset_settings);
/* Please only use this variable in genworld.h and genworld.c and
* nowhere else. For speed improvements we need it to be global, but
@ -256,7 +256,7 @@ void HandleGeneratingWorldAbortion()
* @param size_x The X-size of the map.
* @param size_y The Y-size of the map.
*/
void GenerateWorld(GenerateWorldMode mode, uint size_x, uint size_y)
void GenerateWorld(GenerateWorldMode mode, uint size_x, uint size_y, bool reset_settings)
{
if (_gw.active) return;
_gw.mode = mode;
@ -281,7 +281,7 @@ void GenerateWorld(GenerateWorldMode mode, uint size_x, uint size_y)
GfxLoadSprites();
LoadStringWidthTable();
InitializeGame(_gw.size_x, _gw.size_y, false);
InitializeGame(_gw.size_x, _gw.size_y, false, reset_settings);
PrepareGenerateWorldProgress();
/* Re-init the windowing system */

View File

@ -74,7 +74,7 @@ bool IsGenerateWorldThreaded();
void GenerateWorldSetCallback(gw_done_proc *proc);
void GenerateWorldSetAbortCallback(gw_abort_proc *proc);
void WaitTillGeneratedWorld();
void GenerateWorld(GenerateWorldMode mode, uint size_x, uint size_y);
void GenerateWorld(GenerateWorldMode mode, uint size_x, uint size_y, bool reset_settings = true);
void AbortGeneratingWorld();
bool IsGeneratingWorldAborted();
void HandleGeneratingWorldAbortion();

View File

@ -51,7 +51,7 @@ void InitializeCheats();
void InitializeNPF();
void InitializeOldNames();
void InitializeGame(uint size_x, uint size_y, bool reset_date)
void InitializeGame(uint size_x, uint size_y, bool reset_date, bool reset_settings)
{
/* Make sure there isn't any window that can influence anything
* related to the new game we're about to start/load. */
@ -68,7 +68,7 @@ void InitializeGame(uint size_x, uint size_y, bool reset_date)
_date_fract = 0;
_cur_tileloop_tile = 0;
_thd.redsq = INVALID_TILE;
MakeNewgameSettingsLive();
if (reset_settings) MakeNewgameSettingsLive();
if (reset_date) {
SetDate(ConvertYMDToDate(_settings_game.game_creation.starting_year, 0, 1));

View File

@ -423,6 +423,7 @@ static void DoTriggerIndustryTile(TileIndex tile, IndustryTileTrigger trigger, I
random_bits &= ~object.reseed;
random_bits |= new_random_bits & object.reseed;
SetIndustryRandomBits(tile, random_bits);
MarkTileDirtyByTile(tile);
}
void TriggerIndustryTile(TileIndex tile, IndustryTileTrigger trigger)

View File

@ -771,7 +771,7 @@ static void MakeNewGameDone()
MarkWholeScreenDirty();
}
static void MakeNewGame(bool from_heightmap)
static void MakeNewGame(bool from_heightmap, bool reset_settings)
{
_game_mode = GM_NORMAL;
@ -782,7 +782,7 @@ static void MakeNewGame(bool from_heightmap)
_industry_mngr.ResetMapping();
GenerateWorldSetCallback(&MakeNewGameDone);
GenerateWorld(from_heightmap ? GW_HEIGHTMAP : GW_NEWGAME, 1 << _settings_game.game_creation.map_x, 1 << _settings_game.game_creation.map_y);
GenerateWorld(from_heightmap ? GW_HEIGHTMAP : GW_NEWGAME, 1 << _settings_game.game_creation.map_x, 1 << _settings_game.game_creation.map_y, reset_settings);
}
static void MakeNewEditorWorldDone()
@ -889,7 +889,7 @@ void SwitchToMode(SwitchMode new_mode)
if (new_mode != SM_SAVE) {
/* If the network is active, make it not-active */
if (_networking) {
if (_network_server && (new_mode == SM_LOAD || new_mode == SM_NEWGAME)) {
if (_network_server && (new_mode == SM_LOAD || new_mode == SM_NEWGAME || new_mode == SM_RESTARTGAME)) {
NetworkReboot();
} else {
NetworkDisconnect();
@ -922,13 +922,14 @@ void SwitchToMode(SwitchMode new_mode)
MakeNewEditorWorld();
break;
case SM_RESTARTGAME: // Restart --> 'Random game' with current settings
case SM_NEWGAME: // New Game --> 'Random game'
#ifdef ENABLE_NETWORK
if (_network_server) {
snprintf(_network_game_info.map_name, lengthof(_network_game_info.map_name), "Random Map");
}
#endif /* ENABLE_NETWORK */
MakeNewGame(false);
MakeNewGame(false, new_mode == SM_NEWGAME);
break;
case SM_START_SCENARIO: // New Game --> Choose one of the preset scenarios
@ -974,7 +975,7 @@ void SwitchToMode(SwitchMode new_mode)
snprintf(_network_game_info.map_name, lengthof(_network_game_info.map_name), "%s (Heightmap)", _file_to_saveload.title);
}
#endif /* ENABLE_NETWORK */
MakeNewGame(true);
MakeNewGame(true, true);
break;
case SM_LOAD_HEIGHTMAP: // Load heightmap from scenario editor

View File

@ -14,6 +14,7 @@ enum GameMode {
enum SwitchMode {
SM_NONE,
SM_NEWGAME,
SM_RESTARTGAME,
SM_EDITOR,
SM_LOAD,
SM_MENU,

View File

@ -1516,7 +1516,7 @@ static const SaveLoadFormat *GetSavegameFormat(const char *s)
}
/* actual loader/saver function */
void InitializeGame(uint size_x, uint size_y, bool reset_date);
void InitializeGame(uint size_x, uint size_y, bool reset_date, bool reset_settings);
extern bool AfterLoadGame();
extern bool LoadOldSaveGame(const char *file);
@ -1677,7 +1677,7 @@ SaveOrLoadResult SaveOrLoad(const char *filename, int mode, Subdirectory sb)
/* Load a TTDLX or TTDPatch game */
if (mode == SL_OLD_LOAD) {
_engine_mngr.ResetToDefaultMapping();
InitializeGame(256, 256, true); // set a mapsize of 256x256 for TTDPatch games or it might get confused
InitializeGame(256, 256, true, true); // set a mapsize of 256x256 for TTDPatch games or it might get confused
GamelogReset();
if (!LoadOldSaveGame(filename)) return SL_REINIT;
_sl_version = 0;
@ -1796,7 +1796,7 @@ SaveOrLoadResult SaveOrLoad(const char *filename, int mode, Subdirectory sb)
/* Old maps were hardcoded to 256x256 and thus did not contain
* any mapsize information. Pre-initialize to 256x256 to not to
* confuse old games */
InitializeGame(256, 256, true);
InitializeGame(256, 256, true, true);
GamelogReset();

View File

@ -58,6 +58,7 @@ struct Case {
static bool _masterlang;
static bool _translated;
static bool _translation; ///< Is the current file actually a translation or not
static const char *_file = "(unknown file)";
static int _cur_line;
static int _errors, _warnings, _show_todo;
@ -348,9 +349,10 @@ static void EmitWordList(const char * const *words, uint nw)
uint j;
PutByte(nw);
for (i = 0; i < nw; i++) PutByte(strlen(words[i]));
for (i = 0; i < nw; i++) PutByte(strlen(words[i]) + 1);
for (i = 0; i < nw; i++) {
for (j = 0; words[i][j] != '\0'; j++) PutByte(words[i][j]);
PutByte(0);
}
}
@ -755,14 +757,18 @@ static const CmdStruct *TranslateCmdForCompare(const CmdStruct *a)
return FindCmd("STRING", 6);
}
if (strcmp(a->cmd, "SKIP") == 0) return NULL;
return a;
}
static bool CheckCommandsMatch(char *a, char *b, const char *name)
{
/* If we're not translating, i.e. we're compiling the base language,
* it is pointless to do all these checks as it'll always be correct.
* After all, all checks are based on the base language.
*/
if (!_translation) return true;
ParsedCommandStruct templ;
ParsedCommandStruct lang;
uint i, j;
@ -799,9 +805,9 @@ static bool CheckCommandsMatch(char *a, char *b, const char *name)
/* if we reach here, all non consumer commands match up.
* Check if the non consumer commands match up also. */
for (i = 0; i < lengthof(templ.cmd); i++) {
if (TranslateCmdForCompare(templ.cmd[i]) != TranslateCmdForCompare(lang.cmd[i])) {
if (TranslateCmdForCompare(templ.cmd[i]) != lang.cmd[i]) {
strgen_warning("%s: Param idx #%d '%s' doesn't match with template command '%s'", name, i,
lang.cmd[i] == NULL ? "<empty>" : lang.cmd[i]->cmd,
lang.cmd[i] == NULL ? "<empty>" : TranslateCmdForCompare(lang.cmd[i])->cmd,
templ.cmd[i] == NULL ? "<empty>" : templ.cmd[i]->cmd);
result = false;
}
@ -938,6 +944,10 @@ static void ParseFile(const char *file, bool english)
FILE *in;
char buf[2048];
/* Only look at the final filename to determine whether it's be base language or not */
const char *cur_file = strrchr(_file, PATHSEPCHAR);
const char *next_file = strrchr(file, PATHSEPCHAR);
_translation = next_file != NULL && cur_file != NULL && strcmp(cur_file, next_file) != 0;
_file = file;
/* For each new file we parse, reset the genders, and language codes */

View File

@ -495,22 +495,19 @@ static int DeterminePluralForm(int64 count)
}
}
static const char *ParseStringChoice(const char *b, uint form, char *dst, int *dstlen)
static const char *ParseStringChoice(const char *b, uint form, char **dst, const char *last)
{
/* <NUM> {Length of each string} {each string} */
uint n = (byte)*b++;
uint pos, i, mylen = 0, mypos = 0;
uint pos, i, mypos = 0;
for (i = pos = 0; i != n; i++) {
uint len = (byte)*b++;
if (i == form) {
mypos = pos;
mylen = len;
}
if (i == form) mypos = pos;
pos += len;
}
*dstlen = mylen;
memcpy(dst, b + mypos, mylen);
*dst += seprintf(*dst, last, "%s", b + mypos);
return b + pos;
}
@ -752,7 +749,6 @@ static char *FormatString(char *buff, const char *str, const int64 *argv, uint c
case SCC_GENDER_LIST: { // {G 0 Der Die Das}
const char *s = GetStringPtr(argv_orig[(byte)*str++]); // contains the string that determines gender.
int len;
int gender = 0;
if (s != NULL) {
wchar_t c = Utf8Consume(&s);
@ -766,8 +762,7 @@ static char *FormatString(char *buff, const char *str, const int64 *argv, uint c
/* Does this string have a gender, if so, set it */
if (c == SCC_GENDER_INDEX) gender = (byte)s[0];
}
str = ParseStringChoice(str, gender, buff, &len);
buff += len;
str = ParseStringChoice(str, gender, &buff, last);
break;
}
@ -866,9 +861,7 @@ static char *FormatString(char *buff, const char *str, const int64 *argv, uint c
case SCC_PLURAL_LIST: { // {P}
int64 v = argv_orig[(byte)*str++]; // contains the number that determines plural
int len;
str = ParseStringChoice(str, DeterminePluralForm(v), buff, &len);
buff += len;
str = ParseStringChoice(str, DeterminePluralForm(v), &buff, last);
break;
}