/id issue

A forum for feature requests/discussions and user submitted patches that improve MQ2

Moderator: MacroQuest Developers

TheColonel
of what?
of what?
Posts: 164
Joined: Thu Oct 10, 2002 6:34 pm
Location: Golden, CO
Contact:

/id issue

Post by TheColonel » Sat May 24, 2003 4:40 pm

Works great, 'cept for negative stats, unsigned vs. signed, or a different sign convention, dunno. but 226 isn't -30
Hell hath no fury like a woman's scorn for EQ.
-==(UDIC)==-

User avatar
dont_know_at_all
Developer
Developer
Posts: 5450
Joined: Sun Dec 01, 2002 4:15 am
Location: Florida, USA
Contact:

Post by dont_know_at_all » Sat May 24, 2003 5:19 pm

Specific example?

Amadeus
The Maestro
The Maestro
Posts: 2036
Joined: Sat Jun 29, 2002 3:51 pm

Post by Amadeus » Sat May 24, 2003 8:37 pm

Bug with /identify? This would interest me as well since I've not found an item with a problem.

TheColonel
of what?
of what?
Posts: 164
Joined: Thu Oct 10, 2002 6:34 pm
Location: Golden, CO
Contact:

Post by TheColonel » Mon May 26, 2003 10:22 pm

/id on my Kobold's Jester's Crown USED to give

Code: Select all

[Dec 10 2003] Item: Kobold Jester's Crown (Tiny slot, Weight 0.0, Value 0cp)
[Dec 10 2003] Lore Name: Fool's Crown
[Dec 10 2003] Flags: LORE 
[Dec 10 2003] Item: AC15 -5DEX 5AGI -30INT 30CHA 
Now it gives

Code: Select all

[May 24 2003] Item: Kobold Jester's Crown (Tiny slot, Weight 0.0, Value 0cp)
[May 24 2003] Lore Name: Fool's Crown
[May 24 2003] Flags: LORE 
[May 24 2003] Item: AC15 251DEX 5AGI 226INT 30CHA 
The 251 and 226 look like they're the unsigned equivilent of -5 and -30 in a one byte variable, I didn't look at the struct myself, I suppose... I'll do that and post back.

{EDIT: TRIMMED TIME/DATE STAMPS}
Hell hath no fury like a woman's scorn for EQ.
-==(UDIC)==-

TheColonel
of what?
of what?
Posts: 164
Joined: Thu Oct 10, 2002 6:34 pm
Location: Golden, CO
Contact:

Post by TheColonel » Mon May 26, 2003 10:37 pm

That's really odd... looked at struct, it's all BYTES, doesn't matter, the sprintf's are all %d which SHOULD print a signed dec. Maybe it's just my compiler that's off the standard, I've been using NMAKE on the makefiles, VC6... I'm quite unsure what's wrong, I'll goof around and recompile see if it likes %i better.

Seems like you're gonna need the 'h' qualifier in front of the 'd' '%hd' to specify that it's a short rather than a word.
Hell hath no fury like a woman's scorn for EQ.
-==(UDIC)==-

Amadeus
The Maestro
The Maestro
Posts: 2036
Joined: Sat Jun 29, 2002 3:51 pm

Post by Amadeus » Tue May 27, 2003 12:57 am

That may be true ...I havn't checked back to see how the previous COMMON structure was laid out and how it would be different today. Your fix may be required for negative values to work properly....whatever DKAA says :)

TheColonel
of what?
of what?
Posts: 164
Joined: Thu Oct 10, 2002 6:34 pm
Location: Golden, CO
Contact:

Post by TheColonel » Tue May 27, 2003 1:19 am

Hehe, I've been playing with it, and I can't seem to get it to change how it's displayed, tried '%i' to no avail... tried '%hd'

Code: Select all

if (pCharInfo->Cursor->Common.INT) {
	sprintf(szTmp,"%hdINT ", pCharInfo->Cursor->Common.INT);
	strcat(szMsg,szTmp);
}
and I even type-cast the Common.INT to (int)

Code: Select all

if (pCharInfo->Cursor->Common.INT) {
	sprintf(szTmp,"%dINT ", (int)pCharInfo->Cursor->Common.INT);
	strcat(szMsg,szTmp);
}
So, I dunno, I had some old .h's floating around, but recently cleaned house. I'll probably find out that I'm doing something retarded. But, I'll be up all night, goofin' with it, I'll post when I figure it out.
Hell hath no fury like a woman's scorn for EQ.
-==(UDIC)==-

kaz
a ghoul
a ghoul
Posts: 103
Joined: Tue Jan 14, 2003 4:09 am

Post by kaz » Tue May 27, 2003 7:27 am

just an fyi, the definition of BYTE is unsigned char, so that explains your problem.

change BYTE to char in the struct and the problem should go away.

Amadeus
The Maestro
The Maestro
Posts: 2036
Joined: Sat Jun 29, 2002 3:51 pm

Post by Amadeus » Tue May 27, 2003 1:58 pm

I don't suppose %c would work? Otherwise, yea, it should be changed to CHAR in the struct. Hmmm....I didn't realize that BYTE was unsigned by default....oops!

TheColonel
of what?
of what?
Posts: 164
Joined: Thu Oct 10, 2002 6:34 pm
Location: Golden, CO
Contact:

Post by TheColonel » Wed May 28, 2003 2:16 am

I actually found an old .h and they were stored as BYTEs as well... but they were all... what is word? right after on antoher... either way, in the new struct they're all over the place, dunno if that has anything to do with it, shouldn't, but, I dunno, I play more with ASM than C++ so most of the stuff I do is type independant, not used to having these issues. I'd assume CHAR would work. How long is a SHORT in C++ these days? 2 Bytes I'd assume. But either way, I hacked at the printf things for a whiel and couldn't get it displaying properly, although the mana and HP display correctly, they're LONG's in the struct. I hope this helps, I can't do much more, got a job today, start tomorrow so I can't stay up all hours of the night hacking away anymore.
Hell hath no fury like a woman's scorn for EQ.
-==(UDIC)==-

kaz
a ghoul
a ghoul
Posts: 103
Joined: Tue Jan 14, 2003 4:09 am

Post by kaz » Wed May 28, 2003 3:22 pm

Amadeus wrote:I don't suppose %c would work? Otherwise, yea, it should be changed to CHAR in the struct. Hmmm....I didn't realize that BYTE was unsigned by default....oops!

ok answer is simple, cast to CHAR

Code: Select all

   BYTE x = -30;
   printf("%d", (CHAR)x);
I used this test code just to make sure and it works fine and displays x with the proper sign.

Amadeus
The Maestro
The Maestro
Posts: 2036
Joined: Sat Jun 29, 2002 3:51 pm

Post by Amadeus » Wed May 28, 2003 5:09 pm

That might be the best thing since it's really easy to see it as a BYTE value in the struct if you don't have a negative value to work with. However, the proper answer would be to adjust the struct to CHAR instead of BYTE so that it is correct.


Next time I do a crapload of struct changes for DKAA, I'll be sure to remedy this.

AMadMonk
a lesser mummy
a lesser mummy
Posts: 77
Joined: Tue Sep 24, 2002 9:16 pm

Post by AMadMonk » Wed Jul 09, 2003 2:55 am

A cast of an unsigned value has no implicit sign-extension.

So, BYTE -20 is same thing as BYTE 230. Same data.

However,

BYTE b = -20;
printf("foo: %d", b);

Will NOT sign-extend the value into 32 bits, because, as kaz said, BYTE is an unsigned data type. So you get (+)230 zero-extended into 32 bits which is (drumroll) 230 -- instead of -20 sign-extended into 32 bits which is... uh 2^32-20.

So like kaz said, put in an explicit cast to a signed data type if you want the compiler to do sign-extension. We can't read minds, you know.

xyilla
naggy
naggy
Posts: 33673
Joined: Sun Feb 23, 2025 5:36 am

Re: /id issue

Post by xyilla » Mon Sep 22, 2025 5:49 am


xyilla
naggy
naggy
Posts: 33673
Joined: Sun Feb 23, 2025 5:36 am

Re: /id issue

Post by xyilla » Mon Sep 22, 2025 5:50 am