Welcome to the Builder Academy

Question DB.c Check_bitvector_names

More
11 Jun 2020 19:13 #8772 by Plex
Replied by Plex on topic DB.c Check_bitvector_names
Check_bitvector_names will never work as intended. Check_object passes in 32 bits at a time. Check_bitvector_names puts these 32 bits into a 64 bit variable and looks for invalid bits between 35 and and 64. These bits wouldn’t even exist in the first element of the array. They would be in the second element, but this would get processed the same way. The second element gets passed in and the code evaluates bits 35 thru 64. In order for this to produce valid results we would have to look at the entire array as single chunk of 128 bits and look for any bit greater than 35. The easiest solution might be to pass in the array element so that the function can calculate which bit is actually being evaluated or just pass in the entire array.

From check_object
for(y = 0; y < TW_ARRAY_MAX; y++) {
error |= check_bitvector_names(GET_OBJ_WEAR(obj)[y], wear_bits_count, objname, "object wear");
error |= check_bitvector_names(GET_OBJ_EXTRA(obj)[y], extra_bits_count, objname, "object extra");
error |= check_bitvector_names(GET_OBJ_AFFECT(obj)[y], affected_bits_count, objname, "object affect");
}

GET_OBJ_AFFECT(obj)[y] – int
bits – unsigned long int
namecount – unsigned long int
flagnum – unsigned int

static int check_bitvector_names(bitvector_t bits, size_t namecount, const char *whatami, const char *whatbits)
{
unsigned int flagnum;

for (flagnum = namecount; flagnum < sizeof(bitvector_t) * 8; flagnum++) {
if ((1 << flagnum) & bits) {

Attached is a proposed solution. It will produce the following errors for and object like this.

#1250
unfinished object~
an unfinished object~
An unfinished object is lying here.~
~
0 0 0 0 0 a 0 0 0 dF aF bF aF
0 0 0 0
0 0 0 0 0

Jun 11 13:33:46 2020 :: SYSERR: Object #1250 (an unfinished object) has unknown object affect flag, bit 31 in element 1 (0 through 34 known).
Jun 11 13:33:46 2020 :: SYSERR: Object #1250 (an unfinished object) has unknown object affect flag, bit 1 in element 2 (0 through 34 known).
Jun 11 13:33:46 2020 :: SYSERR: Object #1250 (an unfinished object) has unknown object affect flag, bit 31 in element 2 (0 through 34 known).
Jun 11 13:33:46 2020 :: SYSERR: Object #1250 (an unfinished object) has unknown object affect flag, bit 0 in element 3 (0 through 34 known).
Jun 11 13:33:46 2020 :: SYSERR: Object #1250 (an unfinished object) has unknown object affect flag, bit 31 in element 3 (0 through 34 known).

Attachment check_bitvector_names.txt not found

Please Log in or Create an account to join the conversation.

More
11 Jul 2020 02:44 #8806 by cunning
Replied by cunning on topic DB.c Check_bitvector_names
Very nice. I suspected this all along, I just could not state it as elegant as you did

Please Log in or Create an account to join the conversation.

More
02 May 2024 16:37 #10392 by Salty
Replied by Salty on topic DB.c Check_bitvector_names
Is there any movement or progress on this issue?  The attached solution is not available any longer.

The game and additional bitvectors work just fine but I'm running into the same errors.

Is there any bother in converting to 64 bit as outlined in structs.h ?

Thanks.

Please Log in or Create an account to join the conversation.

More
02 May 2024 20:18 - 02 May 2024 20:38 #10393 by thomas
Replied by thomas on topic DB.c Check_bitvector_names
Hm, looks like the attachment has lost a link when the site crashed a couple of weeks back. I'll see if I can't dig up a link (the file should stil be here, somewhere).

tbamud.com/images/precrash_attachments/c..._bitvector_names.txt
Last edit: 02 May 2024 20:38 by thomas. Reason: Added link to file
The following user(s) said Thank You: Salty

Please Log in or Create an account to join the conversation.

Time to create page: 0.196 seconds