Yes, you are right...its represents that number, I call it a slot number....but not sure if that is a good term for it. Thought it does something for the colors of the player, but cant confirm yet. In Darkplaces lets say your shirt is 4 (red) and you throw an ammo backpack via an impulse. If you set its .colormap to your colormap, the pack turns the color of your shirt (4).
They are also using this:
self.clientcolors = 12 * 16 + 4; // yellow (12) shirt and red (4) pants
...to I guess show the correct color in the scoreboard, which is likely internally identical to that writemessage code you posted.
I messed with my code today, and bitflagged out those floats like I intended, wrote a new bitflag check routine, and found some more illegal colors for the shirts. It was doing an endless loop until I saw I was not setting those team shirt floats to a non zero number, and when you check bitflags like that, the while-do loop was always seeing them as NOT or Zero! So I decided to check them for that first....then return a legal value and also set the float to a non zero so it would not fail the loop next time its picking a color for a client. Not sure if it can be done simpler or not, but so far seems to do the trick.
Code: Select all
float shirt1 = 1; // shirt color 0
float shirt2 = 2; // color 1
float shirt3 = 4;
float shirt4 = 8;
float shirt5 = 16;
float shirt6 = 32;
float shirt7 = 64;
float shirt8 = 128;
float shirt9 = 256;
float shirt10 = 512;
float shirt11 = 1024;
float shirt12 = 2048
float shirt13 = 4096;
float shirt14 = 8192;
float shirt15 = 16384;
float shirt16 = 32768; // color 15
float (float r) MatchBitflag =
{
if (!r)
return shirt1;
if (r == 1)
return shirt2;
if (r == 2)
return shirt3;
if (r == 3)
return shirt4;
if (r == 4)
return shirt5;
if (r == 5)
return shirt6;
if (r == 6)
return shirt7;
if (r == 7)
return shirt8;
if (r == 8)
return shirt9;
if (r == 9)
return shirt10;
if (r == 10)
return shirt11;
if (r == 11)
return shirt12;
if (r == 12)
return shirt13;
if (r == 13)
return shirt14;
if (r == 14)
return shirt15;
if (r == 15)
return shirt16;
};
float (float t, entity ent) TeamGetShirt =
{
local float x,v;
if ((t == TEAM_COLOR1))
{
if (!team1shirt)
{
x = (rint (random () * 12));
v = MatchBitflag (x + 1); // Illegal composite function
team1shirt = team1shirt | (v);
return x;
}
do
{
x = (rint (random () * 15) + 1);
if (x == 14 || x == 15)
{
if (random () < 0.5)
x = 16;
else
x = (rint (random () * 13));
}
if (x - 1 < 0) // Illegal composite function
x = 0;
if (!team1shirt)
return (x - 1); // Illegal composite function
v = MatchBitflag (x);
} while ((team1shirt & v));
team1shirt = team1shirt | (v);
return (x - 1); // Illegal composite function
}
if ((t == TEAM_COLOR2))
{
if (!team2shirt)
{
x = (rint (random () * 10) + 5) ;
v = MatchBitflag (x + 1); // Illegal composite function
team2shirt = team2shirt | (v);
return x;
}
do
{
x = (rint (random () * 15) + 1);
if (x == 4 || x == 5)
{
if (random () < 0.5)
x = (rint (random () * 11) + 5);
else
x = (rint (random () * 2));
}
if (x - 1 < 0) // Illegal composite function
x = 0;
v = MatchBitflag (x);
} while ((team2shirt & v));
team2shirt = team2shirt | (v);
return (x - 1); // Illegal composite function
}
};
Also added some code in setchangeparms() and decodelevelparms() that floats those globals to scratch1 and scratch2 cvars so that they are known
between level changes. Next I need to set a clients bitflag free when they disconnect or go observer.
Also noticed that in Darkplaces, shirtcolor 15 appears as a bright fire orange color in the scoreboard, and the players shirt in the game looks light lime green. I thought maybe darkplaces added more colors..so am checking with LH on that one, strange.....
EDIT / UPDATE:
Found out this code would not work because it uses some ' composite functions ' that are illegal in QC. However most compilers out there wont detect them. I commented my bad code and updated this post today.
r00k wrote:I thought .colormap in stock quake was just the client slot number like when you type status online.