Item Distributor

Results 1 to 7 of 7
  1. #1
    Fuck. SheenBR is offline
    ModeratorRank
    Feb 2008 Join Date
    BrazilLocation
    2,435Posts

    Item Distributor

    I am having a little issue with item distributor... If I create the dat and save it in the postbox if I try to click the NPC my server just crashes.

    I know this is the main routine of Item Distributor in server.exe
    Code:
    005474BA   > FF77 34        PUSH DWORD PTR DS:[EDI+34]               ;  Case 48478A80 of switch 00547420
    005474BD   . FF77 38        PUSH DWORD PTR DS:[EDI+38]
    005474C0   . 56             PUSH ESI
    005474C1   . E8 FC54FFFF    CALL server10.0053C9C2
    And also I do know that my server crashes in this routine:

    Code:
    0044539A  /$ 8A08           /MOV CL,BYTE PTR DS:[EAX]
    0044539C  |. 80F9 20        |CMP CL,20
    0044539F  |. 74 05          |JE SHORT server10.004453A6
    004453A1  |. 80F9 09        |CMP CL,9
    004453A4  |. 75 16          |JNZ SHORT server10.004453BC
    004453A6  |> 40             |INC EAX
    004453A7  |.^EB F1          \JMP SHORT server10.0044539A
    004453A9  |> 80F9 09        /CMP CL,9
    004453AC  |. 74 15          |JE SHORT server10.004453C3
    004453AE  |. 80F9 0A        |CMP CL,0A
    004453B1  |. 74 10          |JE SHORT server10.004453C3
    004453B3  |. 80F9 0D        |CMP CL,0D
    004453B6  |. 74 0B          |JE SHORT server10.004453C3
    004453B8  |. 880A           |MOV BYTE PTR DS:[EDX],CL
    004453BA  |. 42             |INC EDX
    004453BB  |. 40             |INC EAX
    004453BC  |> 8A08            MOV CL,BYTE PTR DS:[EAX]
    004453BE  |. 80F9 20        |CMP CL,20
    004453C1  |.^75 E6          \JNZ SHORT server10.004453A9
    004453C3  |> 8022 00        AND BYTE PTR DS:[EDX],0
    004453C6  \. C3             RETN
    If I remember well is in the MOV CV,BYTE PTR DS:[EAX] instruction..
    Maybe this server has changed the actual "way" those dats works?
    I mean, changed the way you need to create them like:
    char item_code spec message
    to something else?

    If yes, where could I find them? Because I assume someone did it to share with us the way we know how to make it work...

    Thanks


  2. #2
    Grand Master bobsobol is offline
    Grand MasterRank
    May 2007 Join Date
    UKLocation
    5,702Posts

    Re: Item Distributor

    MOV CV,BYTE PTR DS:[EAX]

    There is no CV register. You mean CL.

    I've never seen anyone change the postmaster. I don't actually know many servers that make active use of it, though I've always thought it was an excellent way to pass on "Donation" items. (if it's safe to suggest such an outrageous thing)

  3. #3
    Fuck. SheenBR is offline
    ModeratorRank
    Feb 2008 Join Date
    BrazilLocation
    2,435Posts

    Re: Item Distributor

    yes, I meant CL... but I dont know why my server crash in that offset.. I think its about the dat strucute.. how can I know if this server has changed the postbox structure?

  4. #4
    Grand Master bobsobol is offline
    Grand MasterRank
    May 2007 Join Date
    UKLocation
    5,702Posts

    Re: Item Distributor

    I presume the crash is an "Access violation while reading from address : ??????" type one. Which would suggest that EAX is not pointing to allocated memory, or has not been initialised correctly.

    Knowing what sort of address it is pointing to would help.

    If it is 0 or 1, then that would suggest it has not been initialised. If it is high, and just 1 byte over an allocated memory block (check the memory map) that would suggest this routine isn't breaking out of a "get next character from buffer" loop when it reaches the end.

    But I don't think the actual structure could have changed. Unless they have changed the "end of field" marker. I can't remember how fields are separated just now. A tab, or a space I think. But either way, if this server is looking for some different character, that would explain it.

    --- EDIT ---
    I'm a dumbass. Your code shows the structure.
    Code:
    TrimStart:
    	MOV CL,BYTE PTR [EAX]
    	CMP CL,chSPACE
    	JE .TrimNeeded
    	CMP CL,chTAB
    	JNZ .TrimSpace
    .TrimNeeded:
    	INC EAX
    	JMP TrimStart:
    .Loop:
    	CMP CL,chTAB
    	JE Exit
    	CMP CL,chLF
    	JE Exit
    	CMP CL,cfCR
    	JE Exit
    	MOV BYTE PTR [EDX],CL
    	INC EDX
    	INC EAX
    .TrimSpace:
    	MOV CL,BYTE PTR [EAX]
    	CMP CL,chSPACE
    	JNZ .Loop
    .Exit:
    	AND BYTE PTR [EDX],chNULL
    	RET
    Actually... I could be getting tired, but the code looks borked. What happens if the first character is a Tab? Looks like it then loads the same character again, and tests to see if it's a space as well as a tab in the same byte???

    If the impossible isn't true then it sets the byte to NULL and returns. Also if the space it found isn't any of tab, CR or LF we set it NULL and return.

    --- EDIT ---
    Oh... okay... I think I see. Subtract all non-TAB characters from EAX. (but not EDX) Then subtract all characters that are not Space, Tab, CR or LF from both EAX and EDX. So between EAX and EDX you should be able to determine both the start and end of the string.

    I think.
    Last edited by bobsobol; 23-07-11 at 12:59 AM.

  5. #5
    Sorcerer Supreme Gregoo is offline
    Member +Rank
    Apr 2009 Join Date
    352Posts

    Re: Item Distributor

    On LPT manager I used this code to add a line for the item distributor. Worked perfectly.

    PHP Code:
    $line sprintf('%s%c%c%s%c%c%d%c%c"%s"%c%c%c%c'$character_name0x090x09$item_code0x090x09$spec_or_amount0x090x09str_replace('"'''$message), 0x090x090x0D0x0A); 
    If I recall correctly, the server is expecting 2 tabs between each element and \n\r at the end.

  6. #6
    Fuck. SheenBR is offline
    ModeratorRank
    Feb 2008 Join Date
    BrazilLocation
    2,435Posts

    Re: Item Distributor

    two? I added one and error still remains.. will try with two then and I'll update.

    @edit

    No crashes :))) Thank you gregoo. But now, nothing happens lololol

    @edit2

    I restarted the server after I changed the .dat and everything works fine. Thank you everyone, bob and gregoo.

    This is weird, because all the servers that I tested seems not to care about the alignment.. I always used just one SPACE and always worked... weird, but thanks everyone.
    Last edited by SheenBR; 23-07-11 at 12:53 AM.

  7. #7
    Grand Master bobsobol is offline
    Grand MasterRank
    May 2007 Join Date
    UKLocation
    5,702Posts

    Re: Item Distributor

    Yea... there are places in the configuration files for Monsters and Items and NPCs that need to have two Tabs in them too. I wouldn't be surprised if this code is at fault, but it is way past bedtime for me now. It just looks knotty for some reason.

    --- EDIT ---

    Was really tired when this discussion was taking place, but funnily enough, I had been debugging that same routine earlier on in the evening.

    Your code is the same as any standard server code, so needing double tab would suggest it's being CALLed twice or such?

    In my server I've labelled it TrimCfgParam, as C it would be something like __fastcall int TrimCfgParam(int unimportant, int StartMark).

    Parameters in __fastcall (MS and GNU but not Borland) are passed in ECX and EDX. Curiously, this routine doesn't use ECX, but does use EDX and EAX. It primarily works on EAX, (the return value) and works on EDX as it's secondary value to return.

    It's called everywhere, in any configuration file, on every line which takes a parameter after *COMMAND.

    That includes Hotuk.ini, Bellatra.ini all Items, Monsters and NPCs.

    So if this routine crashes your server... I guess that's quite a bit flaw.
    Last edited by bobsobol; 23-07-11 at 08:07 PM.



Advertisement