Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added authentication and sync to allow special ingame stuff for haxxy…

… winners
  • Loading branch information...
commit ebda451072e480c95161b32b3442979ca0b8b4e9 1 parent 102a20c
@Medo42 authored
View
4 Source/gg2/Constants.xml
@@ -44,6 +44,10 @@
<constant name="SCOPE_IN" value="40"/>
<constant name="SCOPE_OUT" value="41"/>
<constant name="KOTH_UNLOCKCP" value="42"/>
+ <constant name="I_AM_A_HAXXY_WINNER" value="50"/>
+ <constant name="O_RLY" value="51"/>
+ <constant name="YES_RLY" value="52"/>
+ <constant name="HAXXY_PUBLIC_KEY" value="&quot;3cca03b3c2089efdea66a374081d54ed&quot;"/>
<constant name="TEAM_RED" value="0"/>
<constant name="TEAM_BLUE" value="1"/>
<constant name="TEAM_SPECTATOR" value="2"/>
View
2  Source/gg2/Objects/InGameElements/Player.events/Create.xml
@@ -79,6 +79,8 @@
passwordCount = 0;
}
}
+
+ isHaxxyWinner = false;
}
</argument>
</arguments>
View
2  Source/gg2/Objects/InGameElements/Player.events/User Event 12.xml
@@ -33,6 +33,8 @@
if(object != -1) subobjects |= $01;
if(sentry != -1) subobjects |= $02;
+ if(isHaxxyWinner) subobjects |= $04;
+
write_ubyte(global.serializeBuffer, subobjects);
if(object != -1) with(object) event_user(12);
View
2  Source/gg2/Objects/InGameElements/Player.events/User Event 13.xml
@@ -66,6 +66,8 @@
if sentry != -1 with sentry instance_destroy();
sentry = -1;
}
+
+ isHaxxyWinner = (subobjects &amp; $04 != 0)
</argument>
</arguments>
</action>
View
12 Source/gg2/Scripts/Client/ClientBeginStep.gml
@@ -382,11 +382,19 @@ do {
show_message("The server is full.");
instance_destroy();
exit;
-
+
+ case O_RLY:
+ receiveCompleteMessage(global.serverSocket,16,global.tempBuffer);
+ write_ubyte(global.serverSocket, YES_RLY);
+ for(i=1;i<=16;i+=1)
+ write_ubyte(global.serverSocket, read_ubyte(global.tempBuffer) ^ ord(string_char_at(global.haxxyKey, i)));
+ socket_send(global.serverSocket);
+ break;
+
default:
show_message("The Server sent unexpected data");
game_end();
- exit;
+ exit;
}
} else {
break;
View
2  Source/gg2/Scripts/Client/ClientCreate.gml
@@ -40,5 +40,7 @@
buffer_clear(global.sendBuffer);
ClientPlayerJoin(global.playerName);
write_buffer(global.serverSocket, global.sendBuffer);
+ if(global.haxxyKey != "")
+ write_byte(global.serverSocket, I_AM_A_HAXXY_WINNER);
socket_send(global.serverSocket);
}
View
2  Source/gg2/Scripts/GameServer/GameServerDefineCommands.gml
@@ -21,3 +21,5 @@ commandBytes[SCOPE_OUT] = 0;
commandBytes[PASSWORD_SEND] = commandBytesPrefixLength1;
commandBytes[PLAYER_CHANGENAME] = commandBytesPrefixLength1;
commandBytes[INPUTSTATE] = 3;
+commandBytes[I_AM_A_HAXXY_WINNER] = 0;
+commandBytes[YES_RLY] = 16;
View
23 Source/gg2/Scripts/GameServer/processClientCommands.gml
@@ -304,7 +304,28 @@ while(commandLimitRemaining > 0) {
socket_destroy_abortive(player.socket);
player.socket = -1;
}
- break;
+ break;
+
+ case I_AM_A_HAXXY_WINNER:
+ write_ubyte(socket, O_RLY);
+ player.challenge = "";
+ repeat(16)
+ player.challenge += chr(irandom_range(1,255));
+ write_string(socket, player.challenge);
+ break;
+
+ case YES_RLY:
+ var answer, i;
+ answer = "";
+ for(i=1;i<=16;i+=1)
+ answer += chr(read_ubyte(socket) ^ ord(string_char_at(player.challenge, i)));
+ if(HAXXY_PUBLIC_KEY==md5(answer)) {
+ player.isHaxxyWinner = true;
+ } else {
+ socket_destroy_abortive(player.socket);
+ player.socket = -1;
+ }
+ break;
}
break;
}
View
1  Source/gg2/Scripts/_resources.list.xml
@@ -40,4 +40,5 @@
<resource name="selectSpawnGroup" type="RESOURCE"/>
<resource name="partyTime" type="RESOURCE"/>
<resource name="characterHitObstacle" type="RESOURCE"/>
+ <resource name="md5" type="RESOURCE"/>
</resources>
View
2  Source/gg2/Scripts/game_init.gml
@@ -62,6 +62,7 @@
global.caplimitBkup = global.caplimit;
global.autobalance = ini_read_real("Server", "AutoBalance",1);
global.Server_RespawntimeSec = ini_read_real("Server", "Respawn Time", 5);
+ global.haxxyKey = ini_read_string("Haxxy", "SecretHaxxyKey", "");
global.currentMapArea=1;
global.totalMapAreas=1;
global.setupTimer=1800;
@@ -92,6 +93,7 @@
ini_write_real("Server", "Respawn Time", global.Server_RespawntimeSec);
ini_write_real("Server", "Time Limit", global.timeLimitMins);
ini_write_string("Server", "Password", global.serverPassword);
+ ini_write_string("Haxxy", "SecretHaxxyKey", global.haxxyKey);
//screw the 0 index we will start with 1
//map_truefort
View
86 Source/gg2/Scripts/md5.gml
@@ -0,0 +1,86 @@
+/*
+** Usage:
+** md5(str)
+**
+** Arguments:
+** str string from which to compute an MD5 hash (RFC 1321)
+**
+** Returns:
+** an MD5 hash (RFC 1321) computed from the given string
+**
+** Notes:
+** This will only work with strings shorter than 512 megabytes.
+** Precision problems make this unusable in Game Maker 6.
+** For speed this function precomputes four tables in the form
+** of global arrays called MD5k[], MD5g[], MD5r[], and MD5s[].
+**
+** GMLscripts.com
+*/
+{
+ var str,uint,grp,rol,i,j,h,len,pos,w,a,b,c,d,e,f,temp,digest;
+ str = argument0;
+ if (!variable_global_exists("MD5k")) {
+ globalvar MD5k,MD5g,MD5r,MD5s;
+ grp = "00010203040506070809101112131415";
+ grp += "01061100051015040914030813020712";
+ grp += "05081114010407101300030609121502";
+ grp += "00071405120310010815061304110209";
+ rol = "07121722071217220712172207121722";
+ rol += "05091420050914200509142005091420";
+ rol += "04111623041116230411162304111623";
+ rol += "06101521061015210610152106101521";
+ for(i=0; i<64; i+=1) {
+ MD5k[i] = floor(abs(sin(i+1))*(1 << 32));
+ MD5g[i] = real(string_copy(grp,i*2+1,2));
+ MD5r[i] = real(string_copy(rol,i*2+1,2));
+ MD5s[i] = 32 - MD5r[i];
+ }
+ }
+ uint = $FFFFFFFF;
+ h[0] = $67452301;
+ h[1] = $EFCDAB89;
+ h[2] = $98BADCFE;
+ h[3] = $10325476;
+ len = 8 * string_length(str);
+ str += chr(128);
+ while ((string_length(str) mod 64) != 56) str += chr(0);
+ for (i=0; i<64; i+=8) str += chr(len >> i);
+ pos = 0;
+ for (j=0; j<string_length(str); j+=64) {
+ for (i=0; i<16; i+=1) {
+ w[i] = ord(string_char_at(str,pos+4));
+ w[i] = ord(string_char_at(str,pos+3)) | (w[i] << 8);
+ w[i] = ord(string_char_at(str,pos+2)) | (w[i] << 8);
+ w[i] = ord(string_char_at(str,pos+1)) | (w[i] << 8);
+ pos += 4;
+ }
+ a = h[0];
+ b = h[1];
+ c = h[2];
+ d = h[3];
+ for (i=0; i<64; i+=1) {
+ if (i < 16) f = (d ^ (b & (c ^ d)));
+ else if (i < 32) f = (c ^ (d & (b ^ c)));
+ else if (i < 48) f = (b ^ c ^ d);
+ else f = (c ^ (b | (~d)));
+ temp = d;
+ d = c;
+ c = b;
+ e = uint & (a + f + MD5k[i] + w[MD5g[i]]);
+ b = uint & ((uint & (e << MD5r[i]) | (e >> MD5s[i])) + b);
+ a = temp;
+ }
+ h[0] = uint & (h[0] + a);
+ h[1] = uint & (h[1] + b);
+ h[2] = uint & (h[2] + c);
+ h[3] = uint & (h[3] + d);
+ }
+ digest = "";
+ for (j=0; j<4; j+=1) {
+ for (i=0; i<32; i+=8) {
+ digest += string_char_at("0123456789abcdef",1+($F & h[j] >> i+4));
+ digest += string_char_at("0123456789abcdef",1+($F & h[j] >> i));
+ }
+ }
+ return digest;
+}
Please sign in to comment.
Something went wrong with that request. Please try again.