Permalink
Browse files

Simplified "plugins required" flag, some restructuring

  • Loading branch information...
1 parent 99135d0 commit 35162cd57fa28e3468bf08d4631a71b6dcb8d450 @Medo42 committed Mar 4, 2013
@@ -14,12 +14,17 @@
<appliesTo>.self</appliesTo>
<arguments>
<argument kind="STRING">{
- game_init();
+ if(!game_init())
+ {
+ game_end();
+ exit;
+ }
alarm[0] = 30;
alarm[1] = 240;
AudioControlPlaySong(global.FaucetMusic);
image_speed=0;
-}</argument>
+}
+</argument>
</arguments>
</action>
</actions>
@@ -42,6 +42,8 @@ do {
global.joinedServerName = receivestring(global.serverSocket, 1);
downloadMapName = receivestring(global.serverSocket, 1);
advertisedMapMd5 = receivestring(global.serverSocket, 1);
+ receiveCompleteMessage(global.serverSocket, 1, global.tempBuffer);
+ pluginsRequired = read_ubyte(global.tempBuffer);
plugins = receivestring(global.serverSocket, 1);
if(string_pos("/", downloadMapName) != 0 or string_pos("\", downloadMapName) != 0)
{
@@ -50,25 +52,26 @@ do {
exit;
}
- pluginsRequired = false;
- if (string_char_at(plugins, 0) == "*") {
- pluginsRequired = true;
- plugins = string_copy(plugins, 2, string_length(plugins) - 1);
- }
- if (string_length(plugins)) {
+ if (string_length(plugins))
+ {
usePlugins = pluginsRequired;
- if (pluginsRequired) {
- if (!show_question("This server requires the following plugins to play on it: " + plugins + '#They are downloaded from the source: "' + PLUGIN_SOURCE + '"#The source states: "' + PLUGIN_SOURCE_NOTICE + '"#Do you wish to download them and continue connecting?')) {
+ if (pluginsRequired)
+ {
+ if (!show_question("This server requires the following plugins to play on it: " + plugins + '#They are downloaded from the source: "' + PLUGIN_SOURCE + '"#The source states: "' + PLUGIN_SOURCE_NOTICE + '"#Do you wish to download them and continue connecting?'))
+ {
instance_destroy();
exit;
}
- } else {
- if (show_question("This server suggests the following optional plugins to play on it: " + plugins + '#They are downloaded from the source: "' + PLUGIN_SOURCE + '"#The source states: "' + PLUGIN_SOURCE_NOTICE + '"#Do you wish to download them and use them?')) {
+ }
+ else
+ {
+ if (show_question("This server suggests the following optional plugins to play on it: " + plugins + '#They are downloaded from the source: "' + PLUGIN_SOURCE + '"#The source states: "' + PLUGIN_SOURCE_NOTICE + '"#Do you wish to download them and use them?'))
usePlugins = true;
- }
}
- if (usePlugins) {
- if (!loadserverplugins(plugins)) {
+ if (usePlugins)
+ {
+ if (!loadserverplugins(plugins))
+ {
show_message("Error ocurred loading server plugins.");
instance_destroy();
exit;
@@ -86,14 +86,9 @@ case STATE_CLIENT_AUTHENTICATED:
write_ubyte(socket, string_length(global.currentMapMD5));
write_string(socket, global.currentMapMD5);
- var serverPlugins;
- if (global.serverPluginsRequired)
- serverPlugins = "*";
- else
- serverPlugins = "";
- serverPlugins += global.serverPluginList;
- write_ubyte(socket, string_length(serverPlugins));
- write_string(socket, serverPlugins);
+ write_ubyte(socket, global.serverPluginsRequired);
+ write_ubyte(socket, string_length(global.serverPluginList));
+ write_string(socket, global.serverPluginList);
advertisedMap = global.currentMap;
advertisedMapMd5 = global.currentMapMD5;
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<resources>
+ <resource name="loadplugins" type="RESOURCE"/>
+ <resource name="loadserverplugins" type="RESOURCE"/>
+ <resource name="extractzip" type="RESOURCE"/>
+ <resource name="checkpluginname" type="RESOURCE"/>
+ <resource name="pluginscleanup" type="RESOURCE"/>
+</resources>
@@ -3,5 +3,5 @@ if (global.serverPluginsInUse) {
if (show_message_ext("Because you used this server's plugins, you will have to restart GG2 to play on another server.","Restart","","Quit") == 1) {
execute_program(parameter_string(0), "-restart", false);
}
- game_end();
+ game_end();
}
@@ -1,12 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<resources>
<resource name="game_init" type="RESOURCE"/>
- <resource name="loadplugins" type="RESOURCE"/>
- <resource name="loadserverplugins" type="RESOURCE"/>
- <resource name="extractzip" type="RESOURCE"/>
<resource name="deletedir" type="RESOURCE"/>
- <resource name="checkpluginname" type="RESOURCE"/>
- <resource name="pluginscleanup" type="RESOURCE"/>
<resource name="offloadSpawnPoints" type="RESOURCE"/>
<resource name="removePlayer" type="RESOURCE"/>
<resource name="ServerJoinUpdate" type="RESOURCE"/>
@@ -33,6 +28,7 @@
<resource name="Macro" type="GROUP"/>
<resource name="Bytes" type="GROUP"/>
<resource name="Rewards" type="GROUP"/>
+ <resource name="Plugins" type="GROUP"/>
<resource name="recordKillInLog" type="RESOURCE"/>
<resource name="recordDestructionInLog" type="RESOURCE"/>
<resource name="recordEventInLog" type="RESOURCE"/>
@@ -1,12 +1,12 @@
+// Returns true if the game is successfully initialized, false if there was an error and we should quit.
{
instance_create(0,0,RoomChangeObserver);
set_little_endian_global(true);
if file_exists("game_errors.log") file_delete("game_errors.log");
if file_exists("last_plugin.log") file_delete("last_plugin.log");
- var customMapRotationFile, restart, fail;
+ var customMapRotationFile, restart;
restart = false;
- fail = false;
//import wav files for music
global.MenuMusic=sound_add(choose("Music/menumusic1.wav","Music/menumusic2.wav","Music/menumusic3.wav","Music/menumusic4.wav","Music/menumusic5.wav","Music/menumusic6.wav"), 1, true);
@@ -73,7 +73,7 @@
global.serverPluginsRequired = ini_read_real("Server", "ServerPluginsRequired", 0);
if (string_length(global.serverPluginList) > 254) {
show_message("Error: Server plugin list cannot exceed 254 characters");
- fail = true;
+ return false;
}
readClasslimitsFromIni();
@@ -385,12 +385,6 @@ global.launchMap = "";
calculateMonthAndDay();
- if(fail)
- {
- game_end();
- exit;
- }
-
if(!directory_exists(working_directory + "\Plugins")) directory_create(working_directory + "\Plugins");
loadplugins();
@@ -400,4 +394,5 @@ global.launchMap = "";
} else if(restart) {
room_goto_fix(Menu);
}
+ return true;
}

0 comments on commit 35162cd

Please sign in to comment.