19 Feb, 2012, Shaelik wrote in the 1st comment:
Votes: 0
Hi guys, I'm new to this community, and I'm taking on a personal MUD project with Rom 2.4.
I'm looking for exactly what the title suggests, I had seen it many years ago in a MUD, I had played.
This map was almost entirely background colors and let you enter areas from it, and likewise leave areas to the overworld map at an x,y coordinate. Is there any snippet I've overlooked that could accomplish this?
19 Feb, 2012, Zeno wrote in the 2nd comment:
Votes: 0
I think AFKMUD does something like that.
19 Feb, 2012, Shaelik wrote in the 3rd comment:
Votes: 0
Thank you for the quick response!
Hm, I looked into it, but it's coded in C++. I'm not a pro-coder, so I'm looking for something in C, to assimilate into my Rom base. I do appreciate the input!
19 Feb, 2012, Kjwah wrote in the 4th comment:
Votes: 0
The overland code should be straight C
19 Feb, 2012, Runter wrote in the 5th comment:
Votes: 0
I generally think it's easier to express difficult things in C++ when compared to C. So maybe you should be interested in C++ since you can generally write C if you want while getting some powerful features of C++.
19 Feb, 2012, Rarva.Riendf wrote in the 6th comment:
Votes: 0
If you have not start coding yet, better pick another codebase as well. It has numerous 'flaws' that can be very blocking as is.
At least pick the Ram one
19 Feb, 2012, Shaelik wrote in the 7th comment:
Votes: 0
I'm actually using TinyROM, because most of my experience has been with ROM, and this base features color and OLC while compiling with minor warnings under GCC4. I've already got an ascii mapping system implemented, and I'm slowly converting structures over to my own class and stat system. A new base at this point would be blasphemous!
19 Feb, 2012, Ssolvarain wrote in the 8th comment:
Votes: 0
Beware the heretic, the mutant.
19 Feb, 2012, Omega wrote in the 9th comment:
Votes: 0
The code you are referencing that is in AFKmud came from Davion (to load from .png) I know because he gave it to me, and I gave it to samson who added it to afkmud.

this is how it exists today in my mud: (C++ sorry, but you can strip that out easily enough)
bool World::pixel_colour(gdImagePtr im, int pixel, int red, int green, int blue)
{ if( gdImageGreen(im, pixel) == green
&& gdImageRed(im, pixel ) == red
&& gdImageBlue(im, pixel ) == blue )
return true;
return false;
}

// **********************************************************************************************
int World::get_sector_colour(gdImagePtr im, int pixel )
{ int i;

for(i = 0; i <= SECT_MAX; ++i )
{
if( pixel_colour(im, pixel, sector_table[i].rgb[0], sector_table[i].rgb[1], sector_table[i].rgb[2]) )
{
return sector_table[i].sector;
}
}
Log::instance().bug(eLOGLOW,"get_sector_clour: unknown colour type! Does not match anything within the sector_table. Exiting!");
exit (1);
return -1;
}

// **********************************************************************************************
int World::lookup_wild( char type )
{
int x = 0;

for( x = 0; x <= SECT_MAX; ++x )
{
if( sector_table[x].sector == type )
return x;
}
return -1;
}

// **********************************************************************************************
// *Thanks davion for this :), PNG format = HUGE time-saver :)* //
void World::save_map_png(const char *name)
{
/* Declare the image */
gdImagePtr im;
/* Declare output files */
FILE *PngOut;
int terr = 0;
/* Declare color indexes */
int image[SECT_MAX];

im = gdImageCreate(MAX_X, MAX_Y);

for(register int g = 0; g <= SECT_MAX; ++g)
{
image[g] = gdImageColorAllocate(im, sector_table[g].rgb[0], sector_table[g].rgb[1], sector_table[g].rgb[2]);
}

// using registers will give a cpu boost to this, hopefuly allowing us to load faster
for( register int y = 0 ; y < MAX_Y ; ++y )
{
for(register int x = 0; x < MAX_X ; ++x )
{
// *return the number* //
terr = lookup_wild(worldmap[MAP_MAIN][x][y]);

// *Oopsies! something went REALLY wrong* //
if(terr == -1)
terr = 0;

// *Long.. Annoying… Switch* //
gdImageLine(im, x, y, x, y, image[terr]);
}
}

/* Do the same for a JPEG-format file. */
PngOut = fopen(name, "wb");

/* Output the same image in JPEG format, using the default JPEG quality setting. */
gdImagePng(im, PngOut);//, -1);

/* Close the files. */
fclose(PngOut);

for(register int g = 0; g <= SECT_MAX; ++g)
{
gdImageColorDeallocate(im, image[g]);
}


/* Destroy the image in memory. */
gdImageDestroy(im);
im = NULL;
PngOut = NULL;
return;
}

// **********************************************************************************************
void World::save_world_map( const char *name )
{
save_map_png(name);
return;
}

// **********************************************************************************************
void World::load_world_png(const char *name)
{
FILE *pngin;
gdImagePtr im;
int pixel;
int sect;
pngin = fopen(name, "rb");

// *Check to see if we worked or not.* //
if(!pngin)
{
Log::instance().bug(eLOGLOW, "%s: could not load %s!", __PRETTY_FUNCTION__, name);
return;
}

im = gdImageCreateFromPng(pngin);

for( register int y = 0; y < gdImageSY(im) ; ++y )
{
for(register int x = 0; x < gdImageSX(im) ; ++x )
{
pixel = gdImageGetPixel(im, x, y);
if(!strcmp(name, WORLD_FILE))
{
if( ( sect = get_sector_colour(im, pixel ) ) != -1 )
{
worldmap[MAP_MAIN][x][y] = sect;
}
}
else if(!strcmp(name, PATTERN_FILE))
{
int t =0;

// t = mob_pattern(im, pixel );
worldmap[MAP_PATTERN][x][y] = t;
}
else
{
Log::instance().bug(eLOGLOW, "%s: Bad name processed!", __PRETTY_FUNCTION__);
break;
}
}

}

// *Close it down.* //
fclose(pngin);

gdImageDestroy(im);
im = NULL;
pngin = NULL;
return;
}


you'll have to fill in the blanks, like your sector_table, mine has an array for rgb values that you'll need to check against. Thats what creates the worldmap:

A visual of a worldmap would be like:



Sorry about the hot-pink, that is the default colour for water on my world map. (I didn't match them up like I should of… I know….) (and sorry about the size, not sure if we can resize the image here.. someone let me know)

Anyways, my worldmap is 3000x3000, and it loads in, well, fast. I assume this is what you were looking for. I have a full building suite of tools for it as well, lemme know if you need some help and if I can find time I'll help ya out with making it simply C and setting you up with a basic worldmap system.

Also, what was the mud you played? Not too many sport'n a png loading worldmap that I am aware of. ;)
19 Feb, 2012, Davion wrote in the 10th comment:
Votes: 0
Darien said:
The code you are referencing that is in AFKmud came from Davion (to load from .png)


You can also find it in action in alhaen.[link=file]2618[/link] More specifically, you need to look in act_wiz.c at the very, very bottom. do_loadmap. It's called by boot_db. It kinda works, kinda doesn't. Very old code, and didn't remember it till Darien mentioned :P.
19 Feb, 2012, Omega wrote in the 11th comment:
Votes: 0
Yup, there it be! Been a while since I seen Al'haen. I still have the old MSN message where you sent me the code. Good ole fashioned logs!
19 Feb, 2012, Shaelik wrote in the 12th comment:
Votes: 0
Oh wow, that will do nicely, thank you very much for elaborating on that, I think I was looking at the wrong mapper in AFK anyhow.. haha. Wish me luck!

EDIT: Oh, the MUD I played was so long ago, it's tough to remember… I remember Davion's name though, so I'm pretty sure this is the same code.
21 Feb, 2012, Kjwah wrote in the 13th comment:
Votes: 0
When I get back to my PC I can post the overland snippet if anyone needs
0.0/13