Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers AppGameKit Corner / POSSIBLE BUG: SetMemblockInt And GetMemblockInt does not compute :-(

Author
Message
Cybermind
Valued Member
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 4th Mar 2016 10:55 Edited at: 4th Mar 2016 11:39
Hi there stranger and thank you for looking at this

I am trying to use memblocks. I use Tier 1. If I set an INT in mem with SetMemblockInt I don't get the same INT when reading it back with GetMemblockInt, however, if I use the same code but with SetMemblockByte and GetMemblockByte instead I do get the same value when reading back as when I set it. Strange :-P

Something similar, I have some editors made in DBPro. I write longs to file, which is 4 bytes integers, I can't read them as 4 bytes integers in AGK2, BUT I can however create a memblock, read each byte from a 4 byte integer/long into a memblock and THEN retrieve a 4 byte integer correctly in AGK2.

EDIT: I don't think it is a bug, there must be an error elsewhere in my code.

EDIT 2: Changing the last SetMemblockInt(14,b,pre_read_tile_10) and tile = GetMemblockInt(14,m) to SetMemblockByte(14,b,pre_read_tile_10) and tile = GetMemblockByte(14,m) WILL give me the right integer tile number

EDIT 3: I have been writing across boundaries, I think :-P With SetMemblockShort and GetMemblockShort it works, and it fits with 2 bytes for X and Y, 2 bytes for tile number, not trying to write across boundaries

Here is some code:

13/0
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 4th Mar 2016 21:39 Edited at: 4th Mar 2016 22:01
If you are reading two bytes then trying to read an int then you are trying to read across 4 byte boundaries and it is not supported.
Quote: "The offset must be a multiple of 4 as int values cannot be read across 4 byte boundaries."

http://www.appgamekit.com/documentation/Reference/Memblock/GetMemblockInt.htm

maybe try something like this;
Cybermind
Valued Member
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 7th Mar 2016 11:18 Edited at: 7th Mar 2016 11:19
I got it working I did not know about the boundaries Thank you for the nice reply It might just come in handy
13/0

Login to post a reply

Server time is: 2024-04-26 20:25:55
Your offset time is: 2024-04-26 20:25:55