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

 

Seite 14 von 21 « Erste ... 37101112131415161718 ... Letzte »
Ergebnis 261 bis 280 von 410
  1. Beiträge anzeigen #261
    Abenteurer Avatar von redleha
    Registriert seit
    Dec 2010
    Ort
    Новокуйбышевск, Россия
    Beiträge
    68
     
    redleha ist 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?
    Geändert von redleha (07.06.2013 um 10:10 Uhr)

  2. Beiträge anzeigen #262
    General Avatar von Rantragon
    Registriert seit
    May 2008
    Beiträge
    3.903
     
    Rantragon ist 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. Beiträge anzeigen #263
    Dea
    Registriert seit
    Jul 2007
    Beiträge
    10.447
     
    Lehona ist offline
    Zitat Zitat von Rantragon Beitrag anzeigen
    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. Beiträge anzeigen #264
    Abenteurer Avatar von redleha
    Registriert seit
    Dec 2010
    Ort
    Новокуйбышевск, Россия
    Beiträge
    68
     
    redleha ist offline
    Zitat Zitat von Lehona Beitrag anzeigen
    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.
    Geändert von redleha (07.06.2013 um 13:35 Uhr)

  5. Beiträge anzeigen #265
    Dea
    Registriert seit
    Jul 2007
    Beiträge
    10.447
     
    Lehona ist offline
    Zitat Zitat von redleha Beitrag anzeigen
    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. Beiträge anzeigen #266
    Abenteurer Avatar von redleha
    Registriert seit
    Dec 2010
    Ort
    Новокуйбышевск, Россия
    Beiträge
    68
     
    redleha ist offline
    Zitat Zitat von Lehona Beitrag anzeigen
    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. Beiträge anzeigen #267
    Abenteurer Avatar von redleha
    Registriert seit
    Dec 2010
    Ort
    Новокуйбышевск, Россия
    Beiträge
    68
     
    redleha ist 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: ....).
    Geändert von redleha (17.06.2013 um 15:49 Uhr)

  8. Beiträge anzeigen #268
    Dea
    Registriert seit
    Jul 2007
    Beiträge
    10.447
     
    Lehona ist 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. Beiträge anzeigen #269
    Abenteurer Avatar von redleha
    Registriert seit
    Dec 2010
    Ort
    Новокуйбышевск, Россия
    Beiträge
    68
     
    redleha ist 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. Beiträge anzeigen #270
    Dea
    Registriert seit
    Jul 2007
    Beiträge
    10.447
     
    Lehona ist 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. Beiträge anzeigen #271
    Abenteurer Avatar von redleha
    Registriert seit
    Dec 2010
    Ort
    Новокуйбышевск, Россия
    Beiträge
    68
     
    redleha ist 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.
    Geändert von redleha (17.06.2013 um 18:03 Uhr)

  12. Beiträge anzeigen #272
    Dea
    Registriert seit
    Jul 2007
    Beiträge
    10.447
     
    Lehona ist 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. Beiträge anzeigen #273
    Abenteurer Avatar von redleha
    Registriert seit
    Dec 2010
    Ort
    Новокуйбышевск, Россия
    Beiträge
    68
     
    redleha ist 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. Beiträge anzeigen #274
    Dea
    Registriert seit
    Jul 2007
    Beiträge
    10.447
     
    Lehona ist offline
    Zitat Zitat von redleha Beitrag anzeigen
    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. Beiträge anzeigen #275
    Abenteurer Avatar von redleha
    Registriert seit
    Dec 2010
    Ort
    Новокуйбышевск, Россия
    Beiträge
    68
     
    redleha ist 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. Beiträge anzeigen #276
    Dea
    Registriert seit
    Jul 2007
    Beiträge
    10.447
     
    Lehona ist offline
    Zitat Zitat von redleha Beitrag anzeigen
    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. Beiträge anzeigen #277
    Abenteurer Avatar von redleha
    Registriert seit
    Dec 2010
    Ort
    Новокуйбышевск, Россия
    Beiträge
    68
     
    redleha ist 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. Beiträge anzeigen #278
    Abenteurer Avatar von redleha
    Registriert seit
    Dec 2010
    Ort
    Новокуйбышевск, Россия
    Beiträge
    68
     
    redleha ist 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)
    Geändert von redleha (25.06.2013 um 15:40 Uhr)

  19. Beiträge anzeigen #279
    Dea
    Registriert seit
    Jul 2007
    Beiträge
    10.447
     
    Lehona ist 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. Beiträge anzeigen #280
    Abenteurer Avatar von redleha
    Registriert seit
    Dec 2010
    Ort
    Новокуйбышевск, Россия
    Beiträge
    68
     
    redleha ist 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);
    Geändert von redleha (26.06.2013 um 07:51 Uhr) Grund: update 26/06/2013

Seite 14 von 21 « Erste ... 37101112131415161718 ... Letzte »

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
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