Final inventory actor pointer

Post a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is OFF
Smilies are ON

Topic review
   

Expand view Topic review: Final inventory actor pointer

Re: Final inventory actor pointer

by Major Cooke » Wed Apr 06, 2011 2:32 pm

Edit: Nevermind, I'll take a gander.

Re: Final inventory actor pointer

by FDARI » Wed Apr 06, 2011 2:10 pm

New diff patch posted with fix to the recently introduced bug that crashes zdoom.exe. Now, if your zdoom.pk3 is out of date, you may get unexpected behaviour from recently modified functions, but you will not get crashes. If you still do, I'll need your decorate, a description of what happens and some time to myself.

Re: Final inventory actor pointer

by FDARI » Wed Apr 06, 2011 1:57 pm

We're racing to encounter the bugs now. I found one crash-causing bug in my pointer acquisition technique. It shouldn't affect A_GiveToTarget, though, unless you're using the extra parameter for it (not recommended, but possible), or if your PK3-file does not define the extra parameter with a default of AAPTR_DEFAULT (0).

As for the actor spawned; I can go through the code later. If it is a monster, it will most likely be friendly to you. If it is not a monster, I think it will target you as if it were a missile. If I don't get back to you on that, remind me.

Re: Final inventory actor pointer

by Major Cooke » Wed Apr 06, 2011 12:47 pm

Aaah, okay.

Well, this works fine and all but now A_GiveToTarget is causing crashes. I know you suggested the changing of it though so at least I knew how to fix it off the fly.

Another thing, when actors are spawned with A_SpawnItemEx and SXF_TRANSFERPOINTERS, is there any way to tell if it will belong to you or will it not belong to anyone?

Re: Final inventory actor pointer

by Gez » Wed Apr 06, 2011 7:09 am

\ is the escape character. That means that the next character should be interpreted literally, rather than be given some relevance based on its nature. (E.g., \" is just a normal " rather than a string delimiter.)

\newline, therefore, means that the compiler (or the preprocessor) should treat the newline as a normal character rather than as the end of the line. This is very often used to expand macros on several lines for making them more legible, since the preprocessor wants macro definitions to be on a single line.

Re: Final inventory actor pointer

by Major Cooke » Wed Apr 06, 2011 6:29 am

Yeah I didn't word my question properly because it was later in the evening last night, my mistake. Hell I don't even know what I was asking at this point... or remember.

Question, why does your latest patch have \ at the end of a lot of the code lines? I've just never seen that before, I dont know what it means.

Re: Final inventory actor pointer

by FDARI » Wed Apr 06, 2011 2:37 am

I'm not sure what you're asking. If a player fires a seeker missile, the linetarget is automatically put in the tracer field. If you want a missile to acquire its player's linetarget after creation (like a missile that always goes for what you're looking at), you should use A_TransferPointer(int ptr_source, int ptr_recepient, int sourcefield, int recepientfield=AAPTR_DEFAULT, int flags=0); like this:

A_TransferPointer(AAPTR_TARGET, AAPTR_DEFAULT, AAPTR_PLAYER_GETTARGET|AAPTR_NULL, AAPTR_TRACER)

This will get data from TARGET
It will assign data to DEFAULT (self)
The data it will get from TARGET is a player's linetarget. If TARGET is not a player (will not happen if the projectile is only ever created by a weapon) it will get NULL.
It will assign the data to its own TRACER field.

If you use this function to change an actor's master or target, there are safeguards that can be disabled with a flag in the fifth parameter (to prevent a circular chain of references). These safeguards do not apply to a tracer field, nor do any flags.

Any pointer assignment that would cause an actor to point to itself, assigns null instead. (If you have a missile without NOBLOCKMAP, it could possibly become the player's linetarget. However, if assigning the player's linetarget to its tracer field under these circumstances, it will assign null instead. This behaviour cannot be disabled.)

Also: A_RearrangePointers only works with stored pointers. If you wish to store a linetarget, use A_TransferPointers.

I do not recommend storing pointers in player classes, because I'm not sure what the implications are. It may well be nothing more than unused data, but existing mods may depend on players never having data in their target pointer, to make A_GiveToTarget work only when called from a monster (highly unlikely scenario, I know), and there may be a future use for these pointers in the engine (perhaps equally unlikely), or some current use I am not aware of (I doubt it).
Spoiler: Concept: Autolook with FOV

Re: Final inventory actor pointer

by Major Cooke » Tue Apr 05, 2011 7:55 pm

FDARI wrote: Now, to be able to use a player's target correctly in addition to getting a monster's target if it is not a player, use AAPTR_TARGET|AAPTR_PLAYER_GETTARGET. You can also combine AAPTR_PLAYER_GETTARGET with NULL, MASTER, TRACER or DEFAULT (which will naturally be the default combination value). To get target only for players, not for monsters, use AAPTR_NULL|AAPTR_PLAYER_GETTARGET.
Huh... I'm definitely giving this a shot now. So say a projectile has AAPTR_PLAYER_GETTARGET|AAPTR_TRACER, would that basically be something like A_SeekerMissile with the first flag in it? (the auto-looking one) That is, when transferring pointers or rearranging them anyway.

Re: Final inventory actor pointer

by FDARI » Tue Apr 05, 2011 4:07 pm

I discovered that all target-inventory-related code (the original target-codepointers and my code, which was based on their logic), is unable to acquire a player's linetarget. For my code-submission, I added a flag AAPTR_PLAYER_GETTARGET.

Now, to be able to use a player's target correctly in addition to getting a monster's target if it is not a player, use AAPTR_TARGET|AAPTR_PLAYER_GETTARGET. You can also combine AAPTR_PLAYER_GETTARGET with NULL, MASTER, TRACER or DEFAULT (which will naturally be the default combination value). To get target only for players, not for monsters, use AAPTR_NULL|AAPTR_PLAYER_GETTARGET.

Re: Final inventory actor pointer

by FDARI » Wed Mar 30, 2011 5:08 pm

I see no further problems with this patch. The most recent upload in the first post works for all my purposes. Also, I stupidly posted a resource that was dependent on it. That truly was not my intention, but it should make a good demonstration if you have Strife.

Re: Final inventory actor pointer

by Major Cooke » Mon Mar 28, 2011 6:46 am

Here you go.

Bear in mind that it is with GZdoom, actually. It's based off of 1190.

Re: Final inventory actor pointer

by Major Cooke » Mon Mar 28, 2011 6:43 am

Yeah, give me a minute...

Re: Final inventory actor pointer

by FDARI » Mon Mar 28, 2011 4:59 am

Would you be able to distribute your current version to me? I could look at it if I had a diff-patch from the latest svn to your working copy, and possibly your zdoom.pk3 (at least decorate ACTOR and CONSTANTS).

Re: Final inventory actor pointer

by Major Cooke » Sun Mar 27, 2011 6:40 pm

Okay, even after copy/pasting that file over my entire thingdef_codepointers, it didn't change a damn thing. Now I'll look into the rest of the files...

Re: Final inventory actor pointer

by Major Cooke » Sun Mar 27, 2011 4:19 pm

Well, technically yes mine is a bit different because I'm using this... but let me take a gander at it and I'll see what I come up with.

Top