[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  SMAUG
. -> [Folder]  SMAUG coding
. . -> [Subject]  pass pointer of 2d char array into function call?

pass pointer of 2d char array into function call?

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Nargsbrood   (54 posts)  [Biography] bio
Date Fri 06 Oct 2006 04:13 AM (UTC)
Message
i am setting up function that needs to receive a pointer to a 2 dimensional char array. the setup is as follows:

i have the function declared in mud.h:
void plot_map args ( ( CHAR_DATA * ch, int vnum, int xcoord, int ycoord, int tier, int * plotted, char * map ) );


declare map:
char *map[19][19];


call recursive function:
plot_map ( ch, ch->in_room->vnum, 9, 9, 0, plotted, map );


function header:
void plot_map ( CHAR_DATA * ch, int vnum, int xcoord, int ycoord, int tier, int * plotted, char * map )
{



i get this syntax error:
Quote:
act_move.c:3057: warning: passing arg 7 of `plot_map' from incompatible pointer type


anyone know how to properly do this?

[Go to top] top

Posted by Kiasyn Kelle   (15 posts)  [Biography] bio
Date Reply #1 on Fri 06 Oct 2006 04:26 AM (UTC)
Message
uh maybe char **map or char ***map; XD
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #2 on Fri 06 Oct 2006 04:29 AM (UTC)

Amended on Fri 06 Oct 2006 04:30 AM (UTC) by Nick Gammon

Message
Well, they are not the same.

This compiled for me without errors:


void plot_map ( CHAR_DATA * ch, int vnum, int xcoord, int ycoord, int tier, int * plotted, char * map [19][19])


Or you might be better off making a typedef, eg:


typedef char * maptype [19][19] ;

...

void plot_map ( CHAR_DATA * ch, int vnum, int xcoord, int ycoord, int tier, int * plotted, maptype map)
{
  }


...

maptype map;

...

plot_map ( ch, ch->in_room->vnum, 9, 9, 0, plotted, map );



- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nargsbrood   (54 posts)  [Biography] bio
Date Reply #3 on Sat 07 Oct 2006 05:17 AM (UTC)
Message
i've tried a few things and cannot get it to work still:

mud.h declarations:
typedef char maptype  [19][19]  ;
void plot_map args ( ( CHAR_DATA * ch, int vnum, int xcoord, int ycoord, int tier, int * plotted, maptype * map ) );


declare map:
maptype map;


i compile it fine without making any calls to the function. when i then add the function call:
plot_map ( ch, ch->in_room->vnum, 9, 9, 0, plotted, map );


it then gives this same error:
Quote:
act_move.c:3065: warning: passing arg 7 of `plot_map' from incompatible pointer type


-------------

i tried the typedef as
typedef char maptype  [19][19]  ;

as you stated above.
but then it required that i use a * when ever i reference it and so would only let me change the address which was then causing it to crash when i tried to set my values... i want to set the value as 'O' but it would only let me change the address to 'O' which bombs it of course.

anything else come to mind of what i am doing wrong?
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #4 on Sat 07 Oct 2006 05:52 AM (UTC)
Message
Well, you didn't do what I did:

typedef char * maptype [19][19] ;

You left out the * and then tried to put it in later.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #5 on Sat 07 Oct 2006 05:57 AM (UTC)
Message
Or, the way you were doing it:

Quote:

i compile it fine without making any calls to the function. when i then add the function call:

plot_map ( ch, ch->in_room->vnum, 9, 9, 0, plotted, map );



You said you were expecting a pointer to maptype, but only passed it by value. You need to do this:


plot_map ( ch, ch->in_room->vnum, 9, 9, 0, plotted, &map );


Generally when you expect a pointer, you have to take the address with & to generate the pointer.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nargsbrood   (54 posts)  [Biography] bio
Date Reply #6 on Fri 13 Oct 2006 10:21 PM (UTC)
Message
thanks a lot for the help. i was able to do it using a typedef and paying more attention to your recommendations, nick.

What I was doing was making a mapper system which spiders out to build a map of the current area you are in. It is colorized and builds terrain on the map based on the sector type of the room. You do not have to do any map building for your areas and it can be used with all existing areas and can probably stick into any smaug smaug derivitive without having to port... maybe can go into most merc derivitives? (not familiar with presmaug) The only problem is that the rooms have to make sense logically in their layout. going e, s, w, n should end you back up in the same room you began or else it maps it all wierd and doesnt make sense.

I understand programming concepts and am trying to familiarize myself with c concepts... such as passing pointers of different characteristics and what not. That is why i decided to build this mapper from the ground up. When I was done with it(for the most part, have to add nomap flag for roomflags and exitflags) i decided to look for similar snippets to see how they compare. The only 2 that i saw was the overland map code which looks mighty pretty but isnt really a mapping system in that it gives you the lay out of the actual area room to room. and There was also ackmapper which i didnt feel like porting over to smaug simply to take a look at it and couldnt find any screenshots.

Does anyone know of any working muds that use ackmapper?
Or better yet, have any screenshots or know where some are available?
and does anyone know of any other mapping snippets?


Thanks
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #7 on Sat 14 Oct 2006 01:06 AM (UTC)
Message
We had a lengthy discussion about mapping in this thread:

http://www.gammon.com.au/forum/bbshowpost.php?id=7306

That discusses working out where each room leads, and the quickest way to get to another one.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nargsbrood   (54 posts)  [Biography] bio
Date Reply #8 on Sat 14 Oct 2006 03:04 AM (UTC)

Amended on Sat 14 Oct 2006 03:16 AM (UTC) by Nargsbrood

Message
its an interesting discussion and something i have planned on doing in the future. thanks.

It's pretty different from what i was trying to do though. I did not need to find the shortest route of anything. was just mapping out the area and wanted to compare the snippet to other snippets others may know of.

here are screenshots:


[image noborder]www.geocities.com/carlinsmith7/maps.GIF[/image]
(dont know tag for adding the image in this forum, info not found under "what are forum codes?" link. I've seen nick do it before so i assume anyone can)

you can see darkhaven is all jumbled up due to shops seemingly extending into roads behind them. This is where you would use the nomap flag on the room so that it maps the exit to the room and will color the exit a specific color to denote it as a shop but not plot the shop on the map.
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #9 on Sat 14 Oct 2006 11:38 PM (UTC)
Message
Yes, I see what you mean now.

Image posting is an administrator-only function. I am trying to keep bandwidth down, plus make it hard for people to post inappropriate images.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Samson   USA  (683 posts)  [Biography] bio
Date Reply #10 on Mon 16 Oct 2006 03:53 AM (UTC)
Message
Quote:
Does anyone know of any working muds that use ackmapper?


Alsherok uses a mapper which I think Zarius derived from ackmapper. You can get a look at it by logging on to alsherok.net 5500 and getting past the chargen process. It probably doesn't do like you've described with the terrain but it's pretty close.

The overland system is my behemoth of a creation. It wasn't designed to be used for in-area mapping. It's designed to be used for the vastness of space between areas. One person I know of even used it to literally become the vastness of outer space between planets.
[Go to top] top

Posted by Nargsbrood   (54 posts)  [Biography] bio
Date Reply #11 on Mon 16 Oct 2006 05:12 AM (UTC)
Message
thanks for pointing out to check out your mud. I can see what a great asset the overland system is. it's pretty awsome. Removes the need to find 200 ways to describe a dirt trail and makes for a lot more possibility in moving around. There is a lot more to it then the actual display of the map.
[Go to top] top

Posted by Nargsbrood   (54 posts)  [Biography] bio
Date Reply #12 on Mon 16 Oct 2006 05:17 AM (UTC)
Message
i noticed a problem with the help files on alsherok

I can type 'help mptriggers' and can see the help file
I was able to see info for
sectortypes
wizhelp
mapedit
mapout

and others.

i was not able to view mset but when i tried to view it typing
help mset,
it said:
no help on 'mset' found.
sugested help files:
MSET
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


31,272 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]