#PrintText: Access Violation

1 messages · Page 1 of 1 (latest)

solar turtle
#

I think I'm just being a dummy.

The above results in a access violation error on the PrintText line. I know item->binvheight returns a byte, so I tried a few variations of converting it to string (ie. to_string) but still getting the access violation.

Bit new to working with D2 so I'm probably missing something silly 🙂 .

Any tips?

#

Crashes on the xSize PrintText to be specific.

regal reef
#

If binvheight is not a null terminated char* you need to use "xSize: %i"

#

Also I don't know what PrintText() is

gloomy osprey
#
void PrintText(DWORD Color, char* szText, ...) {
    char szBuffer[152] = { 0 };
    va_list Args;
    va_start(Args, szText);
    vsnprintf_s(szBuffer, 152, _TRUNCATE, szText, Args);
    va_end(Args);
    wchar_t Buffer[0x130];
    MultiByteToWideChar(CODE_PAGE, 1, szBuffer, 152, Buffer, 304);
    D2CLIENT_PrintGameString(Buffer, Color);
}

From BH.

solar turtle
#

And yea, to Kanzeon's point, I'm working with a fork of the BH repo

solar turtle
#

(Let me know if I should post follow up questions in new threads)

Idea: Sorting System
Implementation:
I've written an algorithm that will sort items within the player's inventory in a way in which it'll maximize "open space" and keep similar items together. (Only the top 10x4 of the inventory for now. Plans for charms/stash in future iterations)

Problem:
Knowing where I want the items to be placed... depending on available/empty space... the only way to get the items into the correct locations (in the event the inventory is full or nearly full)... is a combination if picking up / putting down and a complicated use of item swapping (swapping the item in the inventory for the item held at the cursor). I am currently working on an algorithm that will determine how to accomplish this in as few steps as possible but even if I implement it perfectly, I feel like it's going to be awful with regard to performance / cleanliness / player perception.

Question:
Is there a way to basically take the items from the inventory, put them in the "void" temporarily... and then, one by one, place them where I want in the inventory? The "void" bit is the (mostly rhetorical) part I don't know about / how to do. Or somehow pickup all of the items at once, and put them down in the correct configuration all at once... Initial testing says no, but I've been testing via packets so far and I would naturally expect the game to reject a packet to pickup a second item as that doesn't make logical sense.

regal reef
#

it should be done as a single custom command packet and the actual sorting done on the server, then resync the inventory back to the client

#

doing it fully client side is bound to cause issues and dangerous to accidentally drop/delete/sell items

solar turtle
#

Might need to pick a different project idea then lol. Don't think I should bother getting into server side stuff yet.

#

I'm a few hours deep in a 20 some odd hour course on reverse engineering. Once s9 is underway and I've at least done what I can on my own, looking forward to picking your brain on that stuff. Will definitely open some more doors as to what projects I could work on to learn with.

regal reef
#

for sure, if you have the algorithm for the sorting, it shouldn't be too difficult to implement on the server

#

at least we've done custom packets plenty of times before, easy to set up another one