Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (Miska), 755 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
lorikob361, LucasJoshua, Baklazhan, Hanky27, firatv
19054 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
GSHashmap DLL #219549
08/03/08 07:13
08/03/08 07:13
Joined: Feb 2006
Posts: 1,011
Germany
pegamode Offline OP
Serious User
pegamode  Offline OP
Serious User

Joined: Feb 2006
Posts: 1,011
Germany
HI everybody,

here is the link to my GSHashmap DLL:

GSHashmap Vesrion 0.8

Feel free to use it ... you may list me in the credits :-)

Post your questions and tips for improvement here.

Best regards,
Pegamode

Re: GSHashmap DLL [Re: pegamode] #220491
08/07/08 11:52
08/07/08 11:52
Joined: Jul 2005
Posts: 1,002
Trier, Deutschland
Nowherebrain Offline
Serious User
Nowherebrain  Offline
Serious User

Joined: Jul 2005
Posts: 1,002
Trier, Deutschland
you may want to put a description in there, I have no idea what this adds. Otherwise I am very curious.


Everybody Poops.
here are some tutorials I made.
http://www.acknexturk.com/blender/
Re: GSHashmap DLL [Re: Nowherebrain] #220893
08/10/08 16:28
08/10/08 16:28
Joined: Feb 2006
Posts: 1,011
Germany
pegamode Offline OP
Serious User
pegamode  Offline OP
Serious User

Joined: Feb 2006
Posts: 1,011
Germany
Hi Nowherebrain,

the add function is declared in c++ as follows:

DLLFUNC void addToGSHashmap(char* key, var value)

So you can add everything to the hashmap that fits into a var.

I use it to store pointers to my struct objects into my hashmap, but
you could also store pointers to entities or whatever.

Hope this helps.

Best regards,
Pegamode

Re: GSHashmap DLL [Re: pegamode] #221188
08/12/08 17:47
08/12/08 17:47
Joined: Apr 2004
Posts: 516
USA
Trooper119 Offline
User
Trooper119  Offline
User

Joined: Apr 2004
Posts: 516
USA
Sorry bud, I'll admit I'm ignorant on this but I have no clue what this is about and I'm sure I'm not alone in this. You'll find your contributions will be long lived if you include the following so people have a clue if your contribution will be helpful to them:

-What is a hashmap?
-Why was this DLL made?
-How does this DLL fit that need?
-Features
-Screenshot/movie if applicable of application working, before and after the DLL is used.
-Step by step of how you implement the DLL into a foreign project.
-Any other points that might be interesting/useful.

If you give people an idea of what they are looking at people will use it and pass it on, otherwise it becomes just another lost contribution.


A clever person solves a problem.
A wise person avoids it.
--Einstein

Currently Codeing: Free Lite-C
Re: GSHashmap DLL [Re: Trooper119] #221234
08/12/08 23:54
08/12/08 23:54
Joined: Jul 2005
Posts: 1,002
Trier, Deutschland
Nowherebrain Offline
Serious User
Nowherebrain  Offline
Serious User

Joined: Jul 2005
Posts: 1,002
Trier, Deutschland
Not to discredit you, but he is right..I have no idea how this would be useful or it's purpose/implementation. I'm not that bright though.

Last edited by Nowherebrain; 08/12/08 23:55.

Everybody Poops.
here are some tutorials I made.
http://www.acknexturk.com/blender/
Re: GSHashmap DLL [Re: Nowherebrain] #221260
08/13/08 06:22
08/13/08 06:22
Joined: Feb 2006
Posts: 1,011
Germany
pegamode Offline OP
Serious User
pegamode  Offline OP
Serious User

Joined: Feb 2006
Posts: 1,011
Germany
Sorry, my fault ...

I thought that a hashmap is well-known as it is a common and one of the most used container in nearly every programming language.

To keep it short:

A hashmap is used to store objects under a unique key in a container and get it back by its key.

For a detailed explanation follow that link:

http://en.wikipedia.org/wiki/Hash_table

As GS doesn't support hashmaps (only a simple type of arrays and some kind of linked lists by using structs), I wrote this dll.

And now a short example how to use my GSHashmap with Lite-C (C-Script should work as well):

Put the GSHashmap.dll into your plugins folder. Usually Lite-C opens DLLs on its own, so you do not have to load it in script. If you have to, just take a look in the GS manual.

Put the file GSHashmap.h into your working directory or whereever you have your header files and add the following line to your main.c:

#include "GSHashmap.h"

That's all you have to do to use the GSHashmap :-)

Now you can use the following functions:

function addToGSHashmap(key,value); // char* key, var value
is used to add a value (for example a pointer or whatever fits in a var)
under a given key into the hashmap:

addToGSHashmap(_chr("myplayer"), ((ENTITY*)player));

function getFromGSHashmap(key);
is used to get the stored values back from the hashmap:

ENTITY* player = (ENTITY*)getFromGSHashmap(_chr("myplayer"));

function clearGSHashmap();
clears all entries from the hashmap.

function removeFromGSHashmap(key);
removes the entry with the given key from the hashmap.

function isInGSHashmap(key); // returns 0 if false, 1 if true
used to check if the entry with the given key exists in the hashmap:

if (isInGSHashmap(_chr("myplayer")) == 1) {
// do something
}

function sizeOfGSHashmap();
returns the current number of entries in the hashmap

***********************************************************************

And here's a short snippet from my project how I use the GSHashmap to store pointers to struct objects filled with data read from a file:

var fhandle;

void filereader() {
fhandle = file_open_read("..\\database\\objects.data");
if (fhandle != 0) {
var tempPointer = 0;
str_cpy(delimit_str,";");
STRING* objName = "";
STRING* str = "";
while (file_str_read(fhandle,objName) != -1) {
USEABLE_OBJECT* tmpObj = (USEABLE_OBJECT*)malloc(sizeof(USEABLE_OBJECT));
file_str_read(fhandle,str);
((USEABLE_OBJECT*)tmpObj).displayName = str_create(str);
file_str_read(fhandle,str);
((USEABLE_OBJECT*)tmpObj).description = str_create(str);
addToGSHashmap(_chr(objName), ((USEABLE_OBJECT*)tmpObj));
file_str_read(fhandle,str);
}
}
file_close(fhandle);
}

***********************************************************************

Hope that helps.

If there are questions ... ask me :-)

Best regards,
Pegamode.

Re: GSHashmap DLL [Re: pegamode] #221364
08/13/08 17:39
08/13/08 17:39
Joined: Apr 2004
Posts: 516
USA
Trooper119 Offline
User
Trooper119  Offline
User

Joined: Apr 2004
Posts: 516
USA
Excellent, exactly what I was talking about, and more. I don't know if you can still edit your first post, but I would change it with what you've just written if you can.

Actually I've worked with Hash Maps before, I just never knew what they were called when I used them lol. I appreciate the explanation and the contribution, good stuff.


A clever person solves a problem.
A wise person avoids it.
--Einstein

Currently Codeing: Free Lite-C
Re: GSHashmap DLL [Re: Trooper119] #221406
08/13/08 20:16
08/13/08 20:16
Joined: Feb 2006
Posts: 1,011
Germany
pegamode Offline OP
Serious User
pegamode  Offline OP
Serious User

Joined: Feb 2006
Posts: 1,011
Germany
Hi Trooper,

I can't edit the first post, but I copied the explanation into a textfile and put it into the rar-File on the server, so there's at least some more info shipped with the dll and header files.

As soon as I find the time I'll write a complete documentation and a short working demo.

I'm currently working on a real StringTokenizer-DLL for a better handling than
what GS supports (90% finished) ...

Regards,
Pegamode.

Re: GSHashmap DLL [Re: pegamode] #224999
09/02/08 14:00
09/02/08 14:00
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
Espér Offline
Expert
Espér  Offline
Expert

Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
isn´t there a way to do it as easy as in RGSS...

here an example: http://www.rmxp.de/scientia/index.php/Hash#Hash

??


Selling my Acknex Engine Editions (A7 Com & A8 Pro):
>> click here if you are interested <<
Re: GSHashmap DLL [Re: Espér] #234192
11/01/08 14:15
11/01/08 14:15
Joined: Feb 2006
Posts: 1,011
Germany
pegamode Offline OP
Serious User
pegamode  Offline OP
Serious User

Joined: Feb 2006
Posts: 1,011
Germany
Hi everybody,

I've added some more functions to GSHashmap.

Now in version 1.0 it is possible to use as many hashmaps as you like, instead of just one ... and it's fully backwards compatible.

You can download the new version here:

GSHashmap Version 1.0

Find more instructions in the rar-File.

Best regards,
Pegamode.

Page 1 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1