logo logo

 Back to main page

The NWNX Community Forum

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
NWNX_Patch
Goto page Previous  1, 2, 3, 4 ... 42, 43, 44  Next
 
Post new topic   Reply to topic    nwnx.org Forum Index -> Windows development
View previous topic :: View next topic  
Author Message
Baaleos



Joined: 02 Sep 2007
Posts: 830

PostPosted: Mon Jan 09, 2017 19:45    Post subject: Reply with quote

Code:

int CNssObject::SetTag(CGameObject *oObject, char *Params) {
   CExoString sNewTag(Params);

   CGameObject *obj = oObject->AsNWSObject();
   if (obj->obj_type2 >= OBJECT_TYPE2_AREA) {
      uint32_t oID = obj->obj_id;

      CNWSModule *Mod = ((*NWN_AppManager)->app_server->srv_internal)->GetModule();
      Mod->RemoveObjectFromLookupTable(obj->obj_tag, oID);
      Mod->AddObjectToLookupTable(sNewTag, oID);

      if (obj->obj_type2 == OBJECT_TYPE2_AREA) {
         CNWSArea *Area = obj->AsNWSArea();
         Area->are_tag = sNewTag;
      }
      else {
         obj->obj_tag = sNewTag;
      }
   }
   return 1;
}


Borrowed from:
https://github.com/addicted2rpg/NWNX2-windows/blob/master/src/NWNX_Functions/CNssObject.cpp

That being said - I don't think are_tag is necessarily a different field. Think it still points to the same area of memory.
The linux symbols seem to use an inheritance model in order to allow the area object to have access to the tag of the underlying object.

Looking at your source code in git -
It looks like you might be able to use the above code, as your api uses the are_tag field in the area object.
Back to top
View user's profile Send private message
DarkSet



Joined: 06 Jun 2016
Posts: 98

PostPosted: Wed Jan 11, 2017 14:45    Post subject: Reply with quote

I just want to mention that nwn_funcs's setTag crushes my server and nwn_patch's not.
Back to top
View user's profile Send private message
ShaDoOoW



Joined: 20 Aug 2005
Posts: 584

PostPosted: Wed Jan 11, 2017 16:30    Post subject: Reply with quote

DarkSet wrote:
I just want to mention that nwn_funcs's setTag crushes my server and nwn_patch's not.

I fixed setting area tag however the above code shown me different issue. If you set tag to object using nwnx_patch this object will not be retrieveable via GetObjectByTag under new tag.

Problem is that if I copypaste the above code it crashes. Looking for solution atm.
_________________
Community Patch / NWNX Patch / NWNX Files / NWNX Connect
Back to top
View user's profile Send private message
Baaleos



Joined: 02 Sep 2007
Posts: 830

PostPosted: Wed Jan 11, 2017 23:13    Post subject: Reply with quote

Can you add debug messages to your method to find the crash point?
The Linux settag seems more simplistic than the Windows symbols.

In order to get the tags to work with getobjectbytag- I would imagine you need the the remove/add to lookup table bits?
Back to top
View user's profile Send private message
Valbor



Joined: 26 Dec 2016
Posts: 145

PostPosted: Thu Jan 12, 2017 9:21    Post subject: Reply with quote

Hello, I recently installed the 1.72 latest. I see that it's a colossal job and a huge thank you ShaDoOoW for it.
Have bugs and some suggestions for your next patch version.

Bugs:
1. If a PC or NPC has Plot status, and use stealth or search mode will not penalty to speed, it standard game bug and i would like to see this fixed.
2. String Disallow Possessing Animal Companion=1 in nwnplayer not working, ie i can always possessing the companion.
3. If you possessing Animal Companion in the game from NWNX, when using the stealth or search mode, then window of portrait at companion's master will disappears from the party and not always appears.

Suggestions:
1. Add additional scripts for other special attacks such as Cleave, Great cleave, Smite good-evil, Called shot, Circle kick, Stunning fist, Ki damage. Also script to trigger sneak attack.
2. In my opinion it was unnecessary to add colored icons of classes, skills etc. in your patch, let it be a separate file for download for those who need it.
Back to top
View user's profile Send private message
ShaDoOoW



Joined: 20 Aug 2005
Posts: 584

PostPosted: Thu Jan 12, 2017 12:31    Post subject: Reply with quote

Baaleos wrote:
Can you add debug messages to your method to find the crash point?
The Linux settag seems more simplistic than the Windows symbols.

In order to get the tags to work with getobjectbytag- I would imagine you need the the remove/add to lookup table bits?

found it

the code from terra has bug and will crash if used on area

it seems obj->obj_tag != are->are_tag

and

Mod->RemoveObjectFromLookupTable(obj->obj_tag, oID);
Mod->AddObjectToLookupTable(sNewTag, oID);

needs to be done separately for area and replace obj->obj_tag with are->are_tag to fix the crash

also it is needed to check if the tag is not NULL (which is by default true for PCs and who knows what else)


EDIT: seems that it creates memory leak either way... this is bad
_________________
Community Patch / NWNX Patch / NWNX Files / NWNX Connect
Back to top
View user's profile Send private message
Terra_777



Joined: 27 Jun 2008
Posts: 216
Location: Sweden

PostPosted: Thu Jan 12, 2017 20:41    Post subject: Reply with quote

I tried to fix the functions from maxrock, decided it wasnt worth my time. If you need to change tag then re-create the item with another tag and if you have to change the tag of an area then you might wanna gff edit the .are before you load it. Or simply iterate all the areas with the same tag and keep them apart by local-stirngs or you could store them as LocalObjects with the var name as your makeshift tag on a waypoint or something.
_________________
I dun have any signature, I'm happy anyway.
Back to top
View user's profile Send private message Send e-mail MSN Messenger
ShaDoOoW



Joined: 20 Aug 2005
Posts: 584

PostPosted: Fri Jan 13, 2017 16:05    Post subject: Re: NWNXPatch_SetTag() function Reply with quote

DarkSet wrote:
Tried to use NWNXPatch_SetTag() function from 70_inc_nwnx library. It works for waypoints, but does not work for area object. There's no error, just area tag remains the same it was.


What do you use SetTag for? I used it only to set PC tag. Terra is right when it comes to setting tag of anything else.

Currently it seems that setting tag works properly in my current plugin build for anything besides areas.

Tag of object can be changed and GetObjectByTag will then work on new tag correctly (that allowed the lines from Terra/MaxRock).

Changing tag of an area seems to work fine too but trying to make it work with GetObjectByTag seems to create memory leak and might result in application crash when shutting down/reloading.

So the possibilities are to allow it and warn users about the possible issues, or just allow change tag but without changing it in internal functions like GetObjectByTag and warn user about it. Or disallow changing tag of an area completely. Opinions?
_________________
Community Patch / NWNX Patch / NWNX Files / NWNX Connect
Back to top
View user's profile Send private message
DarkSet



Joined: 06 Jun 2016
Posts: 98

PostPosted: Fri Jan 13, 2017 16:59    Post subject: Reply with quote

Well, I use SetTag for waypoint for NESS to change spawning objects. And it works.

Also I want to use it to change Item tags for tag based scripting to add/remove on the fly. Now I use item destroy/create with new tag, but it leads to dupe sometimes and I need to deal with it.

And I tried to use it with nwnx_area to set tag of new temporary areas as there are some issues when you create and destroy lots of them from one template and several areas with same tag exist. Some things are done now throug local vars on area object and iterating all areas of the module. Some can be ovverriden as well. So settag for area is not vital for me for now, but nice to have.

How big is the problem of memory leak? How it affect server load and work? My server now have 133h uptime and uses about 1.3 Gb of memory.
If problem is only about troubles with restart - nwnx solves this throu automated process termination, so its not so bad, as not working properly get by tag.

Anyway - maybe you can create a separate function to set tag only for areas and give it two modes - with support of getting by tag and memory leak and without. With comments on top about it?


Actually - maybe you can alter nwnx_areas somehow to allow area tag change on area creation? Like any other object creation function.
I don't think there will be any other area tag setting uses, except for new areas added on the fly.
Back to top
View user's profile Send private message
Terra_777



Joined: 27 Jun 2008
Posts: 216
Location: Sweden

PostPosted: Fri Jan 13, 2017 18:27    Post subject: Reply with quote

nwnx_areas for windows does not destroy the objects within the area it destroyed, its bugged. I re-worked nwnx_areas for windows awhile back to copy the data to all the correct things, preventing the server from crashing when possessing monsters in new areas with the dm client and so forth. You should be able to find it here https://github.com/TerrahKitsune/NWNX there should be pre-compiled binaries in the release tab.

The black area issue can still happen, but you should be able to work around that by using the nwscript functions to reveal/hide the minimap on your online pcs before they enter the area. New areas also do not show up when hovering players in the party-list.
_________________
I dun have any signature, I'm happy anyway.
Back to top
View user's profile Send private message Send e-mail MSN Messenger
ShaDoOoW



Joined: 20 Aug 2005
Posts: 584

PostPosted: Fri Jan 13, 2017 19:06    Post subject: Reply with quote

DarkSet wrote:
How big is the problem of memory leak? How it affect server load and work? My server now have 133h uptime and uses about 1.3 Gb of memory.
If problem is only about troubles with restart - nwnx solves this throu automated process termination, so its not so bad, as not working properly get by tag.

No idea. Its working fine when I tried it. Then I ran it with debugger and when reloading module (after settag on area was used) debugger throwed exception (which happens when there is "memory leak"). Without debugger the reload actually completed but in these cases it can sometimes crash client/server when shutting down. Which might be problem if it "hangs" the process because then nwnx2.exe won't restart it.
_________________
Community Patch / NWNX Patch / NWNX Files / NWNX Connect
Back to top
View user's profile Send private message
DarkSet



Joined: 06 Jun 2016
Posts: 98

PostPosted: Fri Jan 13, 2017 19:08    Post subject: Reply with quote

Thank you Terra. If I remember right I actually use area plugin from you. Never had a problem with black area or minimap, but almost every time have no area name in party portraits hoovering and self portrait hoovering as well.

And I see lots of things in your release tab. Would be great to have some docs for it - what are that plugins, how to use them and whats their state?
Back to top
View user's profile Send private message
DarkSet



Joined: 06 Jun 2016
Posts: 98

PostPosted: Fri Jan 13, 2017 19:14    Post subject: Reply with quote

Quote:
No idea. Its working fine when I tried it. Then I ran it with debugger and when reloading module (after settag on area was used) debugger throwed exception (which happens when there is "memory leak"). Without debugger the reload actually completed but in these cases it can sometimes crash client/server when shutting down. Which might be problem if it "hangs" the process because then nwnx2.exe won't restart it.

well, anyway - proper setTag for all the stuff except areas is great. And about areas it would be nice to have most options possible on the endpoint.

Also - does problem with getByTag mean thet internal things in server app also will not see new area tag?
For example - I create new area from template, it has the same tag. When PC log off area is destroyed. If restart happened failsafe data also is destroyed. And when PC log on again - he is transfered to template area, as it has same tag.

So, if I change new area tag with your non-memory-licking method - will internal NWN server location saving mecanics understand that this is not the same to template location anymore?
Back to top
View user's profile Send private message
DarkSet



Joined: 06 Jun 2016
Posts: 98

PostPosted: Sat Jan 14, 2017 14:03    Post subject: Reply with quote

Found a bug.
I play sorc and somehow have 255 spell uses for the second time. I'm not sure how to repro this, but looks like if I had 0 uses of spell level and item, increasing spell slots when I take this item off - I get 255 spells of corresponding level.

Never had this bug before using nwnx_patch, so I assume it's something with it.
Back to top
View user's profile Send private message
highv priest



Joined: 01 Mar 2013
Posts: 111

PostPosted: Sat Jan 14, 2017 17:00    Post subject: Reply with quote

I can confirm that is a very, very old bug. It happens when releveling with spell slots on your gear. When you drop below the thresh-hold of being able to cast a spell level, and then level back up to that point while maintaining the spell slots on gear, it gives you the rollback effect. This is the reason most servers force you to remove gear when releveling I imagine.

EDIT = Well in addition to circumventing UMD, class, and otherwise restrictions on items.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Windows development All times are GMT + 2 Hours
Goto page Previous  1, 2, 3, 4 ... 42, 43, 44  Next
Page 3 of 44

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group