Contents of the GSC file "_clientids" !Question
-
Question: It is essential to keep the content of the file "_clientids.gsc", since it is the one we use to implement our own gsc, but personally I do not keep the original content of it, which would be this:
init() { level.clientid = 0; level thread onplayerconnect(); } onplayerconnect() { for ( ;; ) { level waittill( "connecting", player ); player.clientid = level.clientid; level.clientid++; } }
Additionally, what is the logic of that code, what does the game need it for?
-
Kalitos the _clientids script is a leftover script. The clientid on the GSC objects aren't used anywhere else in the GSC code, therefore the script can be overwritten by something else.
-
RektInator said in Contents of the GSc file "_clientids" !Question:
Kalitos the _clientids script is a leftover script. The clientid on the GSC objects aren't used anywhere else in the GSC code, therefore the script can be overwritten by something else.
Seems like to me it's actually used quite a lot?
Searching.clientid
in a gsc dump gives quite a few results.Starting to wonder myself why we're able to just patch that out of the gsc.
-
Ox_ I agree with you, although since you mentioned the gsc dump search, I got on it, and if you talk about ".clientid", the game does refer to it, but it directly includes "player.clientid". On the other hand, if we search for level.clientid, we only see that it refers to a single file "_clientids.gsc". It's strange.
-
I know the file existed back in CoD4, and wasn't even used back then IIRC.
To clarify,
player.clientid
's do indeed exist and is (somewhat) used in the game. However this file doesn't handle them at all as you can already tell.Edit :
level.clientid
was probably either supposed to distribute a clientid to every client that connects, or be an array that stores every player's clientid. In the COD4 version of the file, you can find this comment :// Is this safe? What if a server runs for a long time and many people join/leave
-
Probably overwritten by the C++ code of the game then, which would make sense because the C++ code knows the actual client id of the client.
-
Kalitos said in Contents of the GSc file "_clientids" !Question:
Ox_ I agree with you, although since you mentioned the gsc dump search, I got on it, and if you talk about ".clientid", the game does refer to it, but it directly includes "player.clientid". On the other hand, if we search for level.clientid, we only see that it refers to a single file "_clientids.gsc". It's strange.
The
level.clientid
part doesn't seem very interesting or relevant, it just increases and then gives the next player the next number.
But each player getting their ownclientid
field is that interesting part.Searching for uses of that field (the field owner by a player, not the level) in
patch_mp
comes back with 70 matches (few of them in dev blocks though) across 14 different gscs.Sass said in Contents of the GSc file "_clientids" !Question:
I know the file existed back in CoD4, and wasn't even used back then IIRC.
To clarify,
player.clientid
's do indeed exist and is (somewhat) used in the game. However this file doesn't handle them at all as you can already tell.If you replace the _clientids gsc with e.g. this
init() { level thread onPlayerConnect(); } onPlayerConnect() { for(;;) { level waittill("connected", player); player thread onPlayerSpawned(); } } onPlayerSpawned() { self endon("disconnect"); level endon("game_ended"); for(;;) { self waittill("spawned_player"); self iprintln(isDefined(self.clientid)); } }
You'll see that that field indeed doesn't exist if we patch _clientids to not create it.
(As opposed to that field working just as expected if we don't patch _clientids)Makes me wonder how come we're not breaking the functionality in those aforementioned 15 different gscs.
Or perhaps we are, but the functionality there isn't essential. I cba'd to study/test that.