Raised This Month: $51 Target: $400
 12% 

Is SetPackPosition() broken?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
pilger
Senior Member
Join Date: Sep 2010
Old 05-29-2014 , 16:33   Is SetPackPosition() broken?
Reply With Quote #1

Hey guys,

I'm trying to do this:
Code:
        new Handle:data = CloneHandle(datapack);

        ResetPack(data);
        SetPackPosition(data, 5);

        LogMessage("#TEST# %N:%f", client, ReadPackFloat(data));
With no success.

While this:
Code:
        new Handle:data = CloneHandle(datapack);

        ResetPack(data);
        ReadPackCell(data);
        ReadPackCell(data);
        ReadPackCell(data);
        ReadPackCell(data);
        ReadPackCell(data);

        LogMessage("#TEST# %N:%f", client, ReadPackFloat(data));
Works as intended.

They are part of a callback function that interacts with GameMe plugin.

Any thoughts? Is the function SetPackPosition() broken?
pilger is offline
Impact123
Veteran Member
Join Date: Oct 2011
Location: Germany
Old 05-29-2014 , 17:41   Re: Is SetPackPosition() broken?
Reply With Quote #2

I'll leave the details to someone else, but SetPackPosition doesn't really work line an array index.
__________________
Impact123 is offline
pilger
Senior Member
Join Date: Sep 2010
Old 05-29-2014 , 20:38   Re: Is SetPackPosition() broken?
Reply With Quote #3

Hmm. How does it work then? Is it explained somewhere?
pilger is offline
Peace-Maker
SourceMod Plugin Approver
Join Date: Aug 2008
Location: Germany
Old 05-30-2014 , 05:54   Re: Is SetPackPosition() broken?
Reply With Quote #4

You shouldn't be using SetPackPosition. It's setting the position of the internal char* stream to some offset. You'd need to calculate the offset yourself which will likely break easily.

WritePackCell first "pushes" the size of a cell (4 bytes) on the stream then the cell itself (4 bytes again). So you'd need to set the pack position to 5*8=40. It gets trickier with strings in the pack.. You'd be better off with an adt_trie. SetPackPosition should be deprecated as it's of no practical use.
__________________
Peace-Maker is offline
pilger
Senior Member
Join Date: Sep 2010
Old 05-30-2014 , 08:13   Re: Is SetPackPosition() broken?
Reply With Quote #5

Thanks for the info, Peace-Maker.

Well, using adt_trie would be a pain, since I'm just working with GameME's natives. So I guess I'll stick with reading all the unnecessary cells to get to the position I need.

Hope this helps someone with a similar question on the future.
pilger is offline
xf117
Senior Member
Join Date: Mar 2010
Location: Russia
Old 05-30-2014 , 08:37   Re: Is SetPackPosition() broken?
Reply With Quote #6

You still can use SetPackPosition. There is nothing wrong with it if you know the right offset.
xf117 is offline
Send a message via ICQ to xf117
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 06-01-2014 , 11:18   Re: Is SetPackPosition() broken?
Reply With Quote #7

Quote:
Originally Posted by Peace-Maker View Post
SetPackPosition should be deprecated as it's of no practical use.
It has practical use, but you ideally need to be saving the positions as you write.
__________________
asherkin is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 20:08.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode