Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ SMAUG
➜ SMAUG coding
➜ 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 page
Posted by
| Nargsbrood
(54 posts) 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:
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?
| Top |
|
Posted by
| Kiasyn Kelle
(15 posts) Bio
|
Date
| Reply #1 on Fri 06 Oct 2006 04:26 AM (UTC) |
Message
| uh maybe char **map or char ***map; XD | Top |
|
Posted by
| Nick Gammon
Australia (23,162 posts) 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 | Top |
|
Posted by
| Nargsbrood
(54 posts) 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:
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? | Top |
|
Posted by
| Nick Gammon
Australia (23,162 posts) 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 | Top |
|
Posted by
| Nick Gammon
Australia (23,162 posts) 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 | Top |
|
Posted by
| Nargsbrood
(54 posts) 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
| Top |
|
Posted by
| Nick Gammon
Australia (23,162 posts) Bio
Forum Administrator |
Date
| Reply #7 on Sat 14 Oct 2006 01:06 AM (UTC) |
Message
| |
Posted by
| Nargsbrood
(54 posts) 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. | Top |
|
Posted by
| Nick Gammon
Australia (23,162 posts) 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 | Top |
|
Posted by
| Samson
USA (683 posts) 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. | Top |
|
Posted by
| Nargsbrood
(54 posts) 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. | Top |
|
Posted by
| Nargsbrood
(54 posts) 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 | 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.
41,047 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top