razorace Posted April 15, 2003 Share Posted April 15, 2003 Starting this thread to collect information on what varibles in the playerstate_t are open. This is critical since the playerstate_t (gentity_t->ps) is the best way to transfer data to the clients. Slots that ARE Transmitted to the Clients: ints: 7 in ps->stats Definitions: Search for "statIndex_t" in bg_public.c 1 in ps->persistant Definitions: Search for "persEnum_t" in bg_public.c Flags/Buttons: 5 in ps->eFlags Definitions: Search for "#define EF_DEAD" in bg_public.c Slots that AREN'T Transmitted to the Clients: ints: 1 in fullAnimExecute Special thanks to Code for providing information on this. Link to comment Share on other sites More sharing options...
ASk Posted April 16, 2003 Share Posted April 16, 2003 remove Holocron, nobody plays that anyway 3 ints 1 float 1 array of 20 floats Link to comment Share on other sites More sharing options...
Wudan Posted April 16, 2003 Share Posted April 16, 2003 Cool! What I could do with 20 new floats! Link to comment Share on other sites More sharing options...
razorace Posted April 17, 2003 Author Share Posted April 17, 2003 Not only that. That float[20] is only used server side anyway! Meaning we can clear that array for use without losing the holocorn gametype! Link to comment Share on other sites More sharing options...
razorace Posted April 17, 2003 Author Share Posted April 17, 2003 Yep, it works. Just replace all the calls for the array and the 20 floats are yours. Link to comment Share on other sites More sharing options...
Azymn Posted April 17, 2003 Share Posted April 17, 2003 ASk stole mine Also, some of the EF_FLAGS aren't used (at least 4, if i remember right). Also, any free int == 16 new flags. Bitwise operations are a beautiful thing. Link to comment Share on other sites More sharing options...
Commodus Posted April 18, 2003 Share Posted April 18, 2003 You know, after thinking about the IEEE 754 float, I just had an idea: if you can change a 32 bit word into a float, then surely you could change the float back into a word? What I'm trying to say is that if you have an array of 20 floats, you could have up to 640 flags. Maybe I'm going crazy... Link to comment Share on other sites More sharing options...
Fardreamer Posted April 18, 2003 Share Posted April 18, 2003 I've just been using the spare EF bits till now... I desperately need other free bits. Can you be a little more specific about the holocron stuff? Link to comment Share on other sites More sharing options...
Azymn Posted April 18, 2003 Share Posted April 18, 2003 Well, float bits aren't stored in the same manner as ints are, so you can't use integer bitwise operators on them directly. But i think you could cast the floats as WORDs or int to use them as Commodus suggested. Link to comment Share on other sites More sharing options...
razorace Posted April 18, 2003 Author Share Posted April 18, 2003 Well, it's not complicated. Just create a float[20] array inside the gentity_s and then just refer to that new array instead of the array in the playerstate for all the references. Link to comment Share on other sites More sharing options...
razorace Posted April 28, 2003 Author Share Posted April 28, 2003 Found another empty slot in int fullAnimExecute. Link to comment Share on other sites More sharing options...
razorace Posted May 13, 2003 Author Share Posted May 13, 2003 Shazbot! looks like a bunch of the "open" slots we have discussed aren't transmitted over the network. Heck, 75% of the structure doesn't from my new reading of the playerstate structure. Meaning, we need a system to convert a float into a int (and back) to be able to send float data over the network. Anyone got any ideas? Link to comment Share on other sites More sharing options...
Azymn Posted May 13, 2003 Share Posted May 13, 2003 The whole playerstate is transmitted only for each individual client, received as a snapshot ("cg.snap" on the client's end). But only a small number of variables from each client's playerstate is sent to each player. I don't know if any of those variables are open, and many of them are used for multiple things within the clientside code (often not coinciding with the displayed name). Link to comment Share on other sites More sharing options...
Commodus Posted May 13, 2003 Share Posted May 13, 2003 int IeeeToWord(float number) { //first of all: get the sign. int sign; float fractional; int exponent, wholeno, finalword; if (number > 0.0f) { sign = 0; } else if (number < 0.0f) { sign = 1; } else { printf("number is zero!\n"); } fractional = fabs(number); if (((fractional * power(2, 126)) < 1.0f) && ((fractional * power(2, 126)) > 0.0f)) { exponent = 0; fractional *= power(2, 126); } else if (number > 0) { while (fractional > 2.0f) { fractional /= 2; exponent++; } exponent += 127; fractional -= 1.0f; } else if (number < 0) { while (fractional < 0.0f) { fractional *= 2; exponent--; } exponent += 127; } else { printf("number is zero! yet again! \n"); } fractional *= power(2, 23); wholeno = fractional; finalword = (sign << 31) | (exponent << 23) | wholeno; return finalword; } Does this come any close to solving your problem? Link to comment Share on other sites More sharing options...
razorace Posted May 13, 2003 Author Share Posted May 13, 2003 actually, I think so, that's exactly what we needed....I think. Now we need a Word to IEEE function. Link to comment Share on other sites More sharing options...
Commodus Posted May 14, 2003 Share Posted May 14, 2003 float fabs(float number) { if (number > 0) { return number; } else if (number < 0) { return number * -1; } else { return number; } } float power (int x, int y) { int i; int n; float result = 1.0f; float placeholder; if (!y) { return 0; } else if (y == 1) { return x; } else if (y > 1) { for (i = 1; i <= y; i++) { result *= x; } } else if (y < 0) { n = -y; for (i = 1; i <= n; i++) { result *= x; } placeholder = result; result = 1 / placeholder; } else { printf("something went wrong. oops \n"); } return result; } int main() { int word; int sign; int exponent; int presign; double fractional; float number; float powertest; int tobeginwith; powertest = power(2,-23); printf("powertest is %.20f \n", powertest); word = 25; // 01111111111100000000000000000000 presign = word >> 31; //First get the sign if (presign) { sign = -1; } else { sign = 1; } // There is another way, of course - just do -1 to the power of the sign bit //Now get the exponent exponent = word & 2139095040; exponent = exponent >> 23; // kills off the 23 fractional bits, then it switches off the sign bit printf("exponent is %d \n", exponent); //Now get fractional part fractional = (word & 8388607) / power(2, 23); printf("word & 8388607 is %d \n", word & 8388607); printf("fractional is %f \n", fractional); //The next bit checks out the fractional and exponent parts. if (fractional) { if (exponent < 255 && exponent > 0) { number = sign * (power(2, (exponent - 127))) * (1.0f + fractional); printf("number is %8.20f \n", number); tobeginwith = IeeeToWord(number); printf("to begin with we had %d\n", tobeginwith); return 0; } else if (exponent == 255) { //CHECK - if exponent is completely full and fractional is non-zero //then the float is NaN (Not a Number) printf("Word is NaN! \n"); return 0; } else { number = sign * power(2, -126) * fractional; printf("number is %5.15f \n", number); tobeginwith = IeeeToWord(number); printf("to begin with we had %d\n", tobeginwith); } } else { if (!exponent) { number = 0; } if (exponent == 255) { //CHECK - if exponent is completely full then number = infinity * sign //(so possible values are +infinity or -infinity) printf("Word is infinite!\n"); return 0; } } return 0; } I wrote this for wudan so you'll have to adapt it slightly... Link to comment Share on other sites More sharing options...
razorace Posted May 14, 2003 Author Share Posted May 14, 2003 great job Commodus. Looks good but has it been tested? Also, how do you want to be credited for this work? I'm definately going to be using it. Link to comment Share on other sites More sharing options...
razorace Posted May 14, 2003 Author Share Posted May 14, 2003 Updated Slot List. Link to comment Share on other sites More sharing options...
Wudan Posted May 14, 2003 Share Posted May 14, 2003 I can testify to the Word to IEEE conversion, GlaNeo uses it, and the proof is in the results. Link to comment Share on other sites More sharing options...
razorace Posted May 15, 2003 Author Share Posted May 15, 2003 uh, why would you need it for GLANeo? Link to comment Share on other sites More sharing options...
Commodus Posted May 15, 2003 Share Posted May 15, 2003 Well if it doesn't work, then... make it work. It should work though, I checked it ages ago (it was because of the floats and this thread that i made it in the first place). The only problem I can foresee is that numbers might lose accuracy and therefore important bits might be lost (which could be devastating). As for why Neo needs it, well wudan's compiler has problems reading numbers as floats so he needed something to read it. Link to comment Share on other sites More sharing options...
Azymn Posted May 15, 2003 Share Posted May 15, 2003 Perhaps everyone knows where we're determining what variables get transfered and what do not, but it's from the function in bg_misc.c ~line2250: BG_PlayerStateToEntityState() You can see what weird uses they made for variables in there (i.e. bolt2 == dualBlade, clientside...in some areas). There's also another function responsible for the inverse, bringing the entity state back to the ps. Link to comment Share on other sites More sharing options...
razorace Posted May 15, 2003 Author Share Posted May 15, 2003 Yeah, I should have mentioned that. Link to comment Share on other sites More sharing options...
recombinant Posted May 15, 2003 Share Posted May 15, 2003 Thanks! It helps to have a frame of reference for this discussion... Link to comment Share on other sites More sharing options...
LordEradicator Posted May 15, 2003 Share Posted May 15, 2003 Im no expert programmer, but shouldn't: Originally posted by Commodus float fabs(float number) { if (number > 0) { return number; } else if (number < 0) { return number * -1; } else { return number; } } be: float fabs(float number) { if (number < 0) { return number * -1; } else { return number; } } Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.