Portal-Zone Gothic-Zone Gothic II-Zone Gothic 3-Zone Gothic 4-Zone Modifikationen-Zone Download-Zone Foren-Zone RPG-Zone Almanach-Zone Spirit of Gothic

 

Page 14 of 21 « First ... 37101112131415161718 ... Last »
Results 261 to 280 of 410
  1. View Forum Posts #261
    Abenteurer redleha's Avatar
    Join Date
    Dec 2010
    Location
    Новокуйбышевск, Россия
    Posts
    68
     
    redleha is offline
    I implemented a quick transfer of all things from the MobContainer into the inventory of the hero (as like as Gothic3). But I am a little confused by its implementation. It works fine, but the suspicion (that simple).

    Code:
    func void player_hotkey_lame_heal() 
    {
    	//This code will go to a reaction from the drawn button.
    	var oCNpc her;	her = Hlp_GetNpc(hero);
    	var oCMobContainer mobContainer;
    		
    	if(Hlp_Is_oCMobContainer(her.focus_vob))
    	{
    		mobContainer = _^(her.focus_vob);
    	};
    	List_ConcatS(her.inventory2_inventory_next,mobContainer.containList_next);
    	mobContainer.containList_next = 0;
    };
    Save/Load are fine (without switching off the game; and with the switching off and on the game.).
    Is this the normal way?
    Last edited by redleha; 07.06.2013 at 11:10.

  2. View Forum Posts #262
    General Rantragon's Avatar
    Join Date
    May 2008
    Posts
    3,902
     
    Rantragon is offline
    Through this code you will take just 1 item (first), will you? You may use a loop to take all items with one click.

    ...unless you call the function every frame.

    Spoiler:(zum lesen bitte Text markieren)
    sorry for, perhaps, bad english

  3. View Forum Posts #263
    Dea
    Join Date
    Jul 2007
    Posts
    10,172
     
    Lehona is offline
    Quote Originally Posted by Rantragon View Post
    Through this code you will take just 1 item (first), will you? You may use a loop to take all items with one click.

    ...unless you call the function every frame.

    Spoiler:(zum lesen bitte Text markieren)
    sorry for, perhaps, bad english
    No, he's concatenating both lists.

    However, I'm not sure whether Gothic will sort the hero's inventory, because you might have just added an item the hero already possesses. Then there might be two stacks instead of one with a higher amount, you should test that.

    Besides that I can't see anything wrong with your code though.

  4. View Forum Posts #264
    Abenteurer redleha's Avatar
    Join Date
    Dec 2010
    Location
    Новокуйбышевск, Россия
    Posts
    68
     
    redleha is offline
    Quote Originally Posted by Lehona View Post
    However, I'm not sure whether Gothic will sort the hero's inventory, because you might have just added an item the hero already possesses. Then there might be two stacks instead of one with a higher amount, you should test that.

    Besides that I can't see anything wrong with your code though.
    I have in the inventory: the sword, 10 arrows, scroll. Add 150 arrows and 100 coins from the chest.
    Automatic inventory becomes a hero: a sword, 160 arrows, scroll, 100 coins. (And it was done without open inventory and when you open your inventory.)
    I think when you talk about sort, do you mean this?

    Yes, and more. When I tried to remove the object from the zCListSort with List_DeleteS, it was a mistake. I think the problem is to remove the object, which is the last. I think that MEM_Free gives mistake. But I'm not 100% sure, I'll still test.
    Last edited by redleha; 07.06.2013 at 14:35.

  5. View Forum Posts #265
    Dea
    Join Date
    Jul 2007
    Posts
    10,172
     
    Lehona is offline
    Quote Originally Posted by redleha View Post
    I have in the inventory: the sword, 10 arrows, scroll. Add 150 arrows and 100 coins from the chest.
    Automatic inventory becomes a hero: a sword, 160 arrows, scroll, 100 coins. (And it was done without open inventory and when you open your inventory.)
    I think when you talk about sort, do you mean this?

    Yes, and more. When I tried to remove the object from the zCListSort with List_DeleteS, it was a mistake. I think the problem is to remove the object, which is the last. I think that MEM_Free gives mistake. But I'm not 100% sure, I'll still test.
    Good, then that's not a problem.

    You can't just free the memory of the item, you have to call the destructor and hope there aren't any more references etc. The easiest thing to remove an item from a chest is to just add it to an NPCs inventory (similar to the way you've done it) and then use NPC_RemoveInvItem. MEM_Free() should be working properly, doubt there's any problem with it. Post your code and the error messages you get if you need any help

  6. View Forum Posts #266
    Abenteurer redleha's Avatar
    Join Date
    Dec 2010
    Location
    Новокуйбышевск, Россия
    Posts
    68
     
    redleha is offline
    Quote Originally Posted by Lehona View Post
    The easiest thing to remove an item from a chest is to just add it to an NPCs inventory (similar to the way you've done it) and then use NPC_RemoveInvItem.
    Similarly, I have been doing this trick today with the temporary NPC as an intermediate container. I did it and forgot.

  7. View Forum Posts #267
    Abenteurer redleha's Avatar
    Join Date
    Dec 2010
    Location
    Новокуйбышевск, Россия
    Posts
    68
     
    redleha is offline
    Hello again.
    I had such a small problem. As I tried to do the following (lay out in short):
    Code:
    var oCNpc her;	her = Hlp_GetNpc(hero);
    var oCMobContainer mobContainer;
    var int listPtr; 
    if(Hlp_Is_oCMobContainer(her.focus_vob))
    	{
    		mobContainer = _^(her.focus_vob);
    	};
    listPtr = mobContainer.containList_next;
    mobContainer.containList_next = 0;
    List_DestroyS(listPtr); //Once this function causes an error.
    I even moved the function List_DestroyS(listPtr) to other function.
    Each time the game crashes with an error (Q: ....).
    Last edited by redleha; 17.06.2013 at 16:49.

  8. View Forum Posts #268
    Dea
    Join Date
    Jul 2007
    Posts
    10,172
     
    Lehona is offline
    You give me the error message, I try to help you. I won't go fishing the dark without that (You can copy part of zSpy into your clipboard, there's a button for that).

  9. View Forum Posts #269
    Abenteurer redleha's Avatar
    Join Date
    Dec 2010
    Location
    Новокуйбышевск, Россия
    Posts
    68
     
    redleha is offline
    This is log:
    Spoiler:(zum lesen bitte Text markieren)

    [i] 01:10 Info: 2 U: PAR: Adressing an empty Instance : C_NPC.NOFOCUS .... <zParser_Symbol.cpp,#365>
    [f] 01:10 Fault: 0 Q: [start of stacktrace]
    [f] 01:10 Fault: 0 Q: ASMINT_CALLMYEXTERNAL() + 5 bytes
    [f] 01:10 Fault: 0 Q: ASM_RUN(433841104) + 26 bytes
    [f] 01:10 Fault: 0 Q: CALL_BEGIN(433841104) + 26 bytes
    [f] 01:10 Fault: 0 Q: MEM_FREE_(304598712) + 38 bytes
    [f] 01:10 Fault: 0 Q: LIST_DESTROYS(304598712) + 90 bytes
    [f] 01:10 Fault: 0 Q: B_FASTGETITEMS() + 119 bytes
    [f] 01:10 Fault: 0 Q: MEM_CALLBYID(27124) + 224 bytes
    [f] 01:10 Fault: 0 Q: __HOTKEY_DO(5) + 627 bytes
    [f] 01:10 Fault: 0 Q: FOREACHHNDL(9536, __HOTKEY_DO) + 281 bytes
    [f] 01:10 Fault: 0 Q: [UNKNOWN] +-1680519571 bytes
    [f] 01:10 Fault: 0 Q: _HOTKEY_DO() + 157 bytes
    [f] 01:10 Fault: 0 Q: FRAMEFUNCTIONS(4) + 104 bytes
    [f] 01:10 Fault: 0 Q: FOREACHHNDL(9536, __HOTKEY_DO) + 281 bytes
    [f] 01:10 Fault: 0 Q: [UNKNOWN] +-1680519571 bytes
    [f] 01:10 Fault: 0 Q: [end of stacktrace]
    [f] 01:10 Fault: 0 Q: Exception handler was invoked. Ikarus tried to print a Daedalus-Stacktrace to zSpy. Gothic will now crash and probably give you a stacktrace of its own.


    I saw on screen last meesage in MessageBox.

  10. View Forum Posts #270
    Dea
    Join Date
    Jul 2007
    Posts
    10,172
     
    Lehona is offline
    I'm not a 100% sure but you really shouldn't be freeing memory you don't own / haven't allocated yourself. Why do you want to do this anyway? There is no reason to. Wanna delete an item? Switch the node to an NPC and use Npc_RemoveInvItems().
    Technically the game shouldn't have access to the list anymore (you NULL'd the reference), but you never know.

    If you can explain the reason you're doing this I will see if I can do something, but as of now the crash is not caused by a bug in List_DestroyS() and probably related to what I've written above.

  11. View Forum Posts #271
    Abenteurer redleha's Avatar
    Join Date
    Dec 2010
    Location
    Новокуйбышевск, Россия
    Posts
    68
     
    redleha is offline
    I do not know, maybe I'm wrong. But when we separated the inventory to the chest, all that remained in the memory. That's right there was probably clear the debris memory. Or is it not necessary to do?

    P.S. I thought that the function lets you work with any list of games.
    Last edited by redleha; 17.06.2013 at 19:03.

  12. View Forum Posts #272
    Dea
    Join Date
    Jul 2007
    Posts
    10,172
     
    Lehona is offline
    Concatenating a list shouldn't copy it, it's literally appended. Just delete the reference (ie mobContainer.containList_next = 0;) and you should be fine, you won't be leaking any memory.

    Well, you're correct and the function is working perfectly fine. It's just that for some reason freeing the memory causes a crash. I don't really know why but it's working as intended. Don't free memory unless you know you're "allowed" to free it.

  13. View Forum Posts #273
    Abenteurer redleha's Avatar
    Join Date
    Dec 2010
    Location
    Новокуйбышевск, Россия
    Posts
    68
     
    redleha is offline
    Maybe you do not understand.
    In this example, I do not give inventory Hero, I just wanted to remove the entire inventory chest. At all.

  14. View Forum Posts #274
    Dea
    Join Date
    Jul 2007
    Posts
    10,172
     
    Lehona is offline
    Quote Originally Posted by redleha View Post
    Maybe you do not understand.
    In this example, I do not give inventory Hero, I just wanted to remove the entire inventory chest. At all.
    Move the chest inventory to a helper NPC (I think Ikarus provides one anyways, otherwise create your own), null the reference in the chest, clear the npc's inventory. That's how you do it.

  15. View Forum Posts #275
    Abenteurer redleha's Avatar
    Join Date
    Dec 2010
    Location
    Новокуйбышевск, Россия
    Posts
    68
     
    redleha is offline
    Workarounds that I would find. I probably just did not understand the work function ListDestroyS. I think that you can just wipe and free memory space occupied by the object class ListSort.

  16. View Forum Posts #276
    Dea
    Join Date
    Jul 2007
    Posts
    10,172
     
    Lehona is offline
    Quote Originally Posted by redleha View Post
    Workarounds that I would find. I probably just did not understand the work function ListDestroyS. I think that you can just wipe and free memory space occupied by the object class ListSort.
    You can. The problem is: The the list "belongs" to the engine. So you just wipe the memory, but the engine thinks it's still there, tries to act on it and crashes. That's at least what could happen - the crash occurs directly in MEM_Free(), so I assume the memory is somehow protected from being free'd? I don't know. Just don't do it in this case because it's not necessary and will in most cases lead to bad and uncontrolled behaviour.

  17. View Forum Posts #277
    Abenteurer redleha's Avatar
    Join Date
    Dec 2010
    Location
    Новокуйбышевск, Россия
    Posts
    68
     
    redleha is offline
    Thank you. I just wanted to hear the answer.

    I have another question arose. How to get a reference (pointer) to an object of class oCStealContainer?

    As I understand the object of this class is generated based on the inventory of the victim, but a direct connection with it is not (checked by robbing people). Apparently, there is a double deletion (from the visual container and at the same time from the inventory of the victim).
    I guess it is the same there is a combination of fields such as:
    • / / zCListSort <oCItem> {
    •• var int inventory2_inventory_Compare; / / 0x0710 int (_cdecl *) (oCItem *, oCItem *)
    •• var int inventory2_inventory_data; / / 0x0714 oCItem *
    •• var int inventory2_inventory_next; / / 0x0718 zCListSort <oCItem> *

    Or as an option - how to make a visual update of the oCStealContainer, if the removal of items come from outside (through list management (oCNpc.inventory2_inventory_next)).

  18. View Forum Posts #278
    Abenteurer redleha's Avatar
    Join Date
    Dec 2010
    Location
    Новокуйбышевск, Россия
    Posts
    68
     
    redleha is offline
    Hello! That was the question.
    I did a hook on the function:

    Code:
    func void InstallHook_oCInfoManOnChoice()
    {
    	//void __fastcall oCInformationManager::OnChoice(int) 	0x00662780
    	//void __fastcall oCInformationManager::OnChoice(oCInfoChoice *)	0x006629A0
    	const int oCInformationManager__OnChoice = 6694784;	//0x00662780
    	const int oCInformationManager__OnChoice_2 = 6695328;//0x006629A0
    
    		HookEngineF(oCInformationManager__OnChoice, 8, InstallHook_oCInfoManOnChoice__1);
    		HookEngineF(oCInformationManager__OnChoice_2, 8, InstallHook_oCInfoManOnChoice__1);	
    };
    func void InstallHook_oCInfoManOnChoice__1()
    {
    	var int x;
    //[...] ????	
    	MEM_Warn("HOOK");
    };
    How do I get these values ​​of type Int and oСInfoСhoice*


    And the second question.
    How to get the name of the functions inside the function?
    Example:
    Code:
    func string ABCDEF()
    {
    	var string funcName;
    	//[...CODE]
    	return funcName; // = "ABCDEF"
    };
    In fact, the way to read something that will be enough to determine this function? (symbol number in symbolTable, address in memory, or something else)
    Last edited by redleha; 25.06.2013 at 16:40.

  19. View Forum Posts #279
    Dea
    Join Date
    Jul 2007
    Posts
    10,172
     
    Lehona is offline
    If you hook right at the beginning of the function (ie literally the first bytes), then this should do:
    Code:
    var int param; param = MEM_ReadInt(ESP+4);

    Code:
    var int symbID; symbID = MEM_GetFuncIDByOffset(MEM_StackPos.position);
    should get you the symbol of the function.

  20. View Forum Posts #280
    Abenteurer redleha's Avatar
    Join Date
    Dec 2010
    Location
    Новокуйбышевск, Россия
    Posts
    68
     
    redleha is offline
    Thanks, Lehona.

    And could you somehow a way to explain the mechanism of passing parameters to a function and retrieve them?
    Or is it not so easy to explain?
    Maybe if you brought a couple of examples, and work with these ESP, EAX, ECX...

    Edit:
    Right so:

    Code:
    var int param; param = MEM_ReadInt(ESP-4);
    Last edited by redleha; 26.06.2013 at 08:51. Reason: update 26/06/2013

Page 14 of 21 « First ... 37101112131415161718 ... Last »

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Impressum | Link Us | intern
World of Gothic © by World of Gothic Team
Gothic, Gothic 2 & Gothic 3 are © by Piranha Bytes & Egmont Interactive & JoWooD Productions AG, all rights reserved worldwide