Import and rebase Max NewGRFs patch
Fix trailing whitespace, clean up code a bit http://www.tt-forums.net/viewtopic.php?p=894743#p894743
This commit is contained in:

committed by
Jonathan G Rennison

parent
67366cf03d
commit
8f5ef2ae01
@@ -92,9 +92,11 @@ enum FileSlots {
|
|||||||
/** First slot usable for (New)GRFs used during the game. */
|
/** First slot usable for (New)GRFs used during the game. */
|
||||||
FIRST_GRF_SLOT = 2,
|
FIRST_GRF_SLOT = 2,
|
||||||
/** Last slot usable for (New)GRFs used during the game. */
|
/** Last slot usable for (New)GRFs used during the game. */
|
||||||
LAST_GRF_SLOT = 63,
|
LAST_GRF_SLOT = 255,
|
||||||
/** Maximum number of slots. */
|
/** Maximum number of slots. */
|
||||||
MAX_FILE_SLOTS = 64
|
MAX_FILE_SLOTS = 256,
|
||||||
|
/** Maximum number of slots for network game */
|
||||||
|
MAX_FILE_SLOTS_IN_NETWORK = 63
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Mode of the file dialogue window. */
|
/** Mode of the file dialogue window. */
|
||||||
|
@@ -31,6 +31,8 @@
|
|||||||
#include "../core/geometry_func.hpp"
|
#include "../core/geometry_func.hpp"
|
||||||
#include "../genworld.h"
|
#include "../genworld.h"
|
||||||
#include "../map_type.h"
|
#include "../map_type.h"
|
||||||
|
#include "../newgrf.h"
|
||||||
|
#include "../error.h"
|
||||||
|
|
||||||
#include "../widgets/network_widget.h"
|
#include "../widgets/network_widget.h"
|
||||||
|
|
||||||
@@ -1177,6 +1179,10 @@ struct NetworkStartServerWindow : public Window {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case WID_NSS_GENERATE_GAME: // Start game
|
case WID_NSS_GENERATE_GAME: // Start game
|
||||||
|
if (CountSelectedGRFs (_grfconfig_newgame) >= MAX_FILE_SLOTS_IN_NETWORK) {
|
||||||
|
ShowErrorMessage(STR_NEWGRF_ERROR_TOO_MANY_NEWGRFS_LOADED, INVALID_STRING_ID, WL_ERROR);
|
||||||
|
break;
|
||||||
|
}
|
||||||
_is_network_server = true;
|
_is_network_server = true;
|
||||||
if (_ctrl_pressed) {
|
if (_ctrl_pressed) {
|
||||||
StartNewGameWithoutGUI(GENERATE_NEW_SEED);
|
StartNewGameWithoutGUI(GENERATE_NEW_SEED);
|
||||||
|
@@ -9299,3 +9299,16 @@ void LoadNewGRF(uint load_index, uint file_index)
|
|||||||
_tick_counter = tick_counter;
|
_tick_counter = tick_counter;
|
||||||
_display_opt = display_opt;
|
_display_opt = display_opt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns amount of user selected NewGRFs files.
|
||||||
|
*/
|
||||||
|
int CountSelectedGRFs(GRFConfig *grfconf)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
/* Find last entry in the list */
|
||||||
|
for (const GRFConfig *list = grfconf; list != NULL; list = list->next, i++) {
|
||||||
|
}
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
@@ -195,5 +195,6 @@ bool GetGlobalVariable(byte param, uint32 *value, const GRFFile *grffile);
|
|||||||
|
|
||||||
StringID MapGRFStringID(uint32 grfid, StringID str);
|
StringID MapGRFStringID(uint32 grfid, StringID str);
|
||||||
void ShowNewGRFError();
|
void ShowNewGRFError();
|
||||||
|
int CountSelectedGRFs(GRFConfig *grfconf);
|
||||||
|
|
||||||
#endif /* NEWGRF_H */
|
#endif /* NEWGRF_H */
|
||||||
|
@@ -56,6 +56,7 @@
|
|||||||
#include "core/backup_type.hpp"
|
#include "core/backup_type.hpp"
|
||||||
#include "hotkeys.h"
|
#include "hotkeys.h"
|
||||||
#include "newgrf.h"
|
#include "newgrf.h"
|
||||||
|
#include "newgrf_commons.h"
|
||||||
#include "misc/getoptdata.h"
|
#include "misc/getoptdata.h"
|
||||||
#include "game/game.hpp"
|
#include "game/game.hpp"
|
||||||
#include "game/game_config.hpp"
|
#include "game/game_config.hpp"
|
||||||
@@ -845,6 +846,13 @@ int openttd_main(int argc, char *argv[])
|
|||||||
DriverFactoryBase::SelectDriver(musicdriver, Driver::DT_MUSIC);
|
DriverFactoryBase::SelectDriver(musicdriver, Driver::DT_MUSIC);
|
||||||
free(musicdriver);
|
free(musicdriver);
|
||||||
|
|
||||||
|
// Check if not too much GRFs are loaded for network game
|
||||||
|
if (dedicated && CountSelectedGRFs( _grfconfig ) >= MAX_FILE_SLOTS_IN_NETWORK) {
|
||||||
|
DEBUG(net, 0, "Too many GRF loaded. Max %d are allowed.\nExiting ...", MAX_FILE_SLOTS_IN_NETWORK);
|
||||||
|
ShutdownGame();
|
||||||
|
goto exit_normal;
|
||||||
|
}
|
||||||
|
|
||||||
/* Take our initial lock on whatever we might want to do! */
|
/* Take our initial lock on whatever we might want to do! */
|
||||||
_modal_progress_paint_mutex->BeginCritical();
|
_modal_progress_paint_mutex->BeginCritical();
|
||||||
_modal_progress_work_mutex->BeginCritical();
|
_modal_progress_work_mutex->BeginCritical();
|
||||||
|
Reference in New Issue
Block a user