View previous topic :: View next topic |
Author |
Message |
Baaleos
Joined: 02 Sep 2007 Posts: 830
|
Posted: Wed Jul 28, 2010 4:42 Post subject: Bit of a Querk with the Areas Plugin |
|
|
Pretty much, I have found a bit of a querk with the Areas Plugin, in that Deleting an area, while you are inside a previously generated area, can result in a semi-permanent area turning black effect.
Steps to Reproduce:
1. CreateArea("area001");
2. Enter, and leave this area.
3. Set this area to delete itself, 5 seconds after you enter the next area
4. CreateArea("area002");
5. Enter, and wait.
6. Result for me at least: The Area turns black, npc's appear to have vanished, and my player character is not visible either. Opening a door, or toggling a visual effect on myself appears to make everything return to normal though.
I was just wondering if there is any code adjustments that can be done in the areas plugin that would resolve this.
Alternativly, I can change the DestroyArea nss code to conditionally apply a visual effect to players who are inside 'generated' areas, to make their area refresh. |
|
Back to top |
|
|
MaxRock
Joined: 24 Jan 2008 Posts: 196
|
Posted: Wed Jul 28, 2010 6:17 Post subject: |
|
|
Can anybody confirm this behaviour with the linux version? |
|
Back to top |
|
|
Baaleos
Joined: 02 Sep 2007 Posts: 830
|
Posted: Wed Jul 28, 2010 14:36 Post subject: unsure about linux |
|
|
Im unsure about Linux, but I can describe in more detail the circumstances surrounding how I found this querk.
As I have gone on and on about in detail, my Module has a 'Spectral' Realm component to it, where if you die, the area you are in gets auto-duplicated by the areas plugin, and the area properties changed to look like the underworld.
Well, I decided I wanted to delete un-needed spectral realms, and as such, implimented a Pseudoheart Beat which starts when a player leaves the Spectral Realm.
It checks
1. Is there any players in the Spectral Realm copy of the area.
2. Is there any players in the Material Realm original of the area
3. Is there any players who are currently Transitioning. (eg - GetArea(oPC) == OBJECT_INVALID)
1. This is self explanitory, we dont wana delete the area if its occupied.
2. We dont wana delete areas if someone might be capable of transitioning into the area just as we give the delete command.
3. Since we cannot get the area of players in between areas, we treat a transitioning player, as a potential occupant of the area.
Each of these 3 criteria, is enough to continue the pseudo hb.
The HB Stops, and Fires the DestroyArea command, when all 3 of the criteria return 0.
In anycase, the scenario that first revealed this querk happened as such.
I died in the Slums
Respawned
Appeared in the Slums Spectral Realm.
Left the Slums Spectral Realm, returning to the Slums Material Realm
The system still knows I am a potential Occupant of the Spectral Realm, so...
I then enter a House in the Slums
When I appear in the House - who's Interior was generated via CreateArea(), the HB finally recognizes I am over 1 transition away from entering the Spectral Realm, and as such, knows it is safe to delete it.
5 Second delay starts . . . . .
Destroyed Area, and POOF!!
Lights out for me inside the Generated Interior of my lovely little Slums Housing.
My initial speculation, is that the Area Minimap data or the Area date loses its index or something in the Area List.
eg Spectral Realm = Area 13
Interior = Area 14
Deleting the Spectral Realm, somehow doesnt correctly index the area which was generated after the Spectral Realm or something.
But, as said, It is fix-able via nwnscript. When I toggled Stealth on my character, which is hooked to apply a visual effect, it made my character appear again, and a few seconds later, made the rest of the area appear.
Correction - Visual Effects do not resolve the issue. The only thing that seems able to make the area appear again, is to interact with a door or similar placeable in the area. Eg - Open the Door.
I think a RecomputeOfStaticLighting might fix the issue, but thats a cpu heavy function.
Interestingly enough, I can still see light sources, such as torches etc, when the area is black etc. So the area does exist, it just seems to be the lighting of the area that gets disrupted. |
|
Back to top |
|
|
Baaleos
Joined: 02 Sep 2007 Posts: 830
|
Posted: Sat Jul 31, 2010 2:59 Post subject: Discovered a more preciece way to cause another bug |
|
|
Generate area
Enter Area,
Log off in Area
Re-Enter
When you re-enter, the area will be black.
In one case, this even caused a crash for me. At memory location
129d70
Which is part of the ExploreArea function.
Is there any ides on potential fixes? |
|
Back to top |
|
|
Baaleos
Joined: 02 Sep 2007 Posts: 830
|
Posted: Sat Jul 31, 2010 3:38 Post subject: |
|
|
I think I may have a potential cause of this error.
This issue only occurs to players who are logged in, at the time of the area creation.
Suggesting that the first part of this issue occurs at the Create Area call, which Sends the Area data to players.
Eg - AddToCreatures or whatever it is called.
Ok, so, this data is added to Creatures in a sorta artifical way.
However, when somone logs in for the first time, the Module itself sends the Area data for all areas, to the player, and they get it in the authentic way.
For whatever reason or not, When the first player, who was logged in at the time of area creation, logs out, and then in, the area data is being lost from their Turd (I think) - God that sounds awful.
But for some reason, Player 2, who logged in after the area was created, doesnt lose his area visibility, because for some reason, he received his area data in a different way, and his view of the same area remains intact dispite logging off and in.
Its like his Turd is valid, and Player 1's turd is not, or at least the area data in them is differing.
Would it be possible to re-send Area's To Creatures on login, to fix this?
Note - I recorded a video of this bug in action, to help you recreate and possibly be a genius and devise a solution. hehe.
http://www.youtube.com/watch?v=xRKRsltcohQ |
|
Back to top |
|
|
Baaleos
Joined: 02 Sep 2007 Posts: 830
|
Posted: Sat Jul 31, 2010 4:17 Post subject: |
|
|
Working on my own fix.
Do you think this will work?
Code: |
else if(strncmp(Request, "RESEND_AREA", 11) ==0) {
ReSendAreaToCreatures(strtol(Parameters, (char **)NULL, 16));
}
|
Code: |
int CNWNXAreas::ReSendAreaToCreatures(nwn_objid_t nAreaID)
{
CNWSArea* pArea = ((*NWN_AppManager)->app_server->srv_internal)->GetAreaByGameObjectID(nAreaID);
if (!pArea) return 0;
char *pMod = (char*)((*NWN_AppManager)->app_server->srv_internal)->GetModule();
CNWSModule *pModule = (CNWSModule*)(pMod+0x1C);
uint32_t nAreaID2 = *((uint32_t *)pArea+0x32);
AddAreaToCreatures(pModule, nAreaID2);
UpdateAreasForDMs();
return 1;
}
|
The idea, is that when a player logs in, the area data will be resent for the area targetted.
Since we have GetNextArea() via nwn_funcs, looping through all areas, should be possible, to re-add all the areas to all the currently logged in creatures. |
|
Back to top |
|
|
Baaleos
Joined: 02 Sep 2007 Posts: 830
|
Posted: Sat Jul 31, 2010 5:25 Post subject: |
|
|
HOLY SHIT.
IT WORKED.
I fixed a bug.... YEOW!!
Lol
Well, its not really a fix, but its more like a patch.
I bet you guys could find an easier or more impressive way of fixing it.
I tested this out, by logging into the black area, and then calling a voice command
+area
and a moment later, the area loaded
Although... come to think of it, the way I have it implimented, will cause a momentary blackout for every player in the game.
Grrr...
That 'better solution' is looking nicer and nicer round about now. Lol
Or.. maybe not.. I mean, its only sending the one area, to all players.
Meaning they shouldnt black out, if they are not in that area.
Ooooh, using my newly learned skills,
I can set the local string on the player who is to receive the minimap updates, and then it will target just him? |
|
Back to top |
|
|
Baaleos
Joined: 02 Sep 2007 Posts: 830
|
Posted: Sat Jul 31, 2010 5:54 Post subject: |
|
|
OMG -
I HAVE COMETH!!
Lmao
Code: |
int CNWNXAreas::ReSendAreaToCreatures(nwn_objid_t nAreaID, char *gameObject)
{
CNWSCreature *pObject = (CNWSCreature*)gameObject;
//CNWSCreature *cre = (CNWSCreature*)gameObject;
if (pObject->obj.obj_generic.obj_type2 == 5)
{
if (pObject->cre_areaminimaps)
{
char *pMod = (char*)((*NWN_AppManager)->app_server->srv_internal)->GetModule();
CNWSModule *pModule = (CNWSModule*)(pMod+0x1C);
pObject->cre_areaminimaps = (void**)realloc(pObject->cre_areaminimaps, pModule->mod_areas_len *4);
void *pMinimap = new char[0x80];
memset(pMinimap, 0, 0x80);
pObject->cre_areaminimaps[pModule->mod_areas_len-1] = pMinimap;
CExoArrayList_uint32_add((CExoArrayList_uint32*)&pObject->cre_arealist, nAreaID);
_log(3, "o Creature area count: %d\n", pObject->cre_areacount);
}
}
return 1;
}
|
This allows the module to update the minimaps for an individual player, I think, to refresh the blackout effect, and get rid of it.
Took me a while to understand how to do it, I studied the original method, and saw that it gets all the objects in the game, by getting an array from inside an array so to speak.
I simply bypassed that step, since we just need one character/creature, the one being targetted.
ARGH... CRAP..
Quote: |
- StrReq: "CREATE_AREA" Params: "sarafaninfirm"
o AreaCount: 33
o Area added
o Module Area Count: 34
o Adding minimap to creature '7FFFFFFD'
o Creature area count: 34
+ ObjReq: 07B2260C Request: GET_LAST_AREA_ID
- StrReq: "RESEND_AREA" Params: "85b"
o Creature area count: 34
- StrReq: "RESEND_AREA" Params: "85b"
o Creature area count: 35
- StrReq: "RESEND_AREA" Params: "85b"
o Creature area count: 36
- StrReq: "RESEND_AREA" Params: "85b"
o Creature area count: 37
|
I hope its not adding the new area each time..
Well, the good news is that its not, it just seems that the Array that they are stored in, thinks that it has got extra areas in it. They dont seem to be showing in the dm area list.
But then again... Im not exactly running the dm update code am I.. Lol
Question...
Is there not a nwn native function, which sends the minimaps to players on their login?
Im assuming they only get sent on the players First Login to the game?
Would it not be easier, to just call that function again.
Players who come into the server AFTER the areas were generated, have no problems,
its just people who were in the server or had been in the server, prior to the area being generated.
I suspect that the Minimaps are only sent to players on the first login, probably as a way of conserving bandwidth or something? |
|
Back to top |
|
|
Baaleos
Joined: 02 Sep 2007 Posts: 830
|
Posted: Sat Jul 31, 2010 6:02 Post subject: eeek. |
|
|
A player joined the server, and it crashed.
129d70 - I will look this offset up in the morning. |
|
Back to top |
|
|
MaxRock
Joined: 24 Jan 2008 Posts: 196
|
Posted: Sat Jul 31, 2010 20:42 Post subject: |
|
|
Something is "wrong" with the linked list.
They might have a different layout on linux which is where I copied the definition from:
Code: |
struct CExoLinkedListHeader {
Element *First;
Element *Last;
}
class CExoLinkedList {
CExoLinkedListHeader *ListHeader;
uint32 Count;
}
|
Yet when I look at the memory of a running server (windows), the 'Count' seems to be part of the header.
I changed that to get the clearTURDList function to work, which in turn broke the areas plugin.
Problem is that if the linked list layout works different on windows then adding (or removing) an area, which updated the count will overwrite a wrong memory location... |
|
Back to top |
|
|
Baaleos
Joined: 02 Sep 2007 Posts: 830
|
Posted: Sat Jul 31, 2010 20:50 Post subject: which translates to? |
|
|
Lol, alot of that went over my head.
But I generally got the gist of it as
'ClearTurdList - in order to get this to work, you needed to make changes to a class, which then in turn broke Areas plugin'
Is this something that is fixable?
I mean, The pseudo fix I came up with, to re-send the area data to players does work, although I did get a crash when a new player entered the game....
But my main problem really, is that Black Universe bug.
About 75% of my module is reliant on the areas plugin's capabilities, and it kinda scares me that a player could experience blackouts if they log out and in again.
Im pretty sure they will get the blackout if they log out in or outside of a generated area, eg - re-entering the area via a door will give black area too.
I had a look to see if there was a internal nwn function which sends all the areas to the player on first login.
I couldnt find anything at first glance.
Do you have any ideas on how to fix the black universe bug?
It seems to be something to do with the area data is not stored persistently on players, and gets lost when the log out and in.
Like Turd Data is overwriting it. |
|
Back to top |
|
|
|
|
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
|