Station Name Patch?
Moderator: OpenTTD Developers
i think i may have actually got it working... but i'm waiting for it too compile... WOOT
edit: i was wrong... just changed it to "OFF edge of map" (in white)
edit: now its called the town name... although i think it cycles through names now...
Edit: updated the patch (beta 2, one error... station numbers randomly change value while placing a new station with the new station name formulae)
edit: i was wrong... just changed it to "OFF edge of map" (in white)
edit: now its called the town name... although i think it cycles through names now...
Edit: updated the patch (beta 2, one error... station numbers randomly change value while placing a new station with the new station name formulae)
- Attachments
-
- Frudinghall Transport, 21st May 1950.png (143.36 KiB) Viewed 1146 times
-
- station_name.patch
- the patch so far... unlimited station names... but no new naming yet
- (1.16 KiB) Downloaded 196 times
-
- station_name.patch
- only works with english currently (for testing)
- (2.12 KiB) Downloaded 175 times
Last edited by Salvo_guy on 01 Aug 2006 14:52, edited 2 times in total.
I'm stupid.... but i found what i was looking for in the end
i believe something like this would be the best way to show a Statation Number and never run out of different station names .... just make it do the same thing as trains (except this would be for all players and there wouldnt be any backwards counting) . In this case there should also be a boolean value to say if it should show the station number or not. i think this is a good step before makeing it town and or player related if thats what you want to do. Doing it this way would mean you would have to save these new values but i doubt it would be hard to work out as you have the other code to look at.
Good luck
Code: Select all
static void TrainViewWndProc(Window *w, WindowEvent *e)
......
......
SetDParam(0, v->string_id);
SetDParam(1, v->unitnumber);
DrawWindowWidgets(w);
Good luck
What exactly is it that you want?
As i understand it you want to have
In the end whatever you get this done it will be good.
As i understand it you want to have
As I understand it currenly it is only possible to store one string for a station name. Every possiblitly has its own string "town name east" "town name west" etc etc so to get around this you add all the places where it displays the station name which is around 6 i think (you would also need to change this to display "town name" + "east" or "town name" + "east" + "woods") and this method would also work well for extending names of stations adding numbers to all of the existing strings but the first idea would be easier to achive just adding the number in which the station was build with the town name.
"town name" + "number" or a combination of other station names? ie "town name" + "east" + "woods
or "town name" + "south" + "sidings"
In the end whatever you get this done it will be good.
Last edited by l_Blue_l on 29 Jul 2006 03:59, edited 1 time in total.
hmm.. i'll try and think about what you've just said... but i have a problem...
I'm getting a mysterious "if" and "else" syntax error.. and ideas?
Edit: if you would like to tell me what i'm doing wrong here.. that would b great.. and if that would b likely to work...
I'm getting a mysterious "if" and "else" syntax error.. and ideas?
Code: Select all
static bool GenerateStationName(Station *st, TileIndex tile, int flag)
{ static unsigned char STNUM;
STNUM = 0; //neccessary to have unlimited station names
}
if (STNUM == 0) {
static const uint32 _gen_station_name_bits[] = {
0, /* 0 */
1 << M(STR_SV_STNAME_AIRPORT), /* 1 */
1 << M(STR_SV_STNAME_OILFIELD), /* 2 */
1 << M(STR_SV_STNAME_DOCKS), /* 3 */
0x1FF << M(STR_SV_STNAME_BUOY_1), /* 4 */
1 << M(STR_SV_STNAME_HELIPORT), /* 5 */
};
Town *t = st->town;
uint32 free_names = (uint32)-1;
int found;
uint z,z2;
unsigned long tmp;
{
Station *s;
FOR_ALL_STATIONS(s) {
if (s != st && s->xy != 0 && s->town==t) {
uint str = M(s->string_id);
if (str <= 0x20) {
if (str == M(STR_SV_STNAME_FOREST))
str = M(STR_SV_STNAME_WOODS);
CLRBIT(free_names, str);
}
}
}
}
/* check default names */
tmp = free_names & _gen_station_name_bits[flag];
if (tmp != 0) {
found = FindFirstBit(tmp);
goto done;
}
/* check mine? */
if (HASBIT(free_names, M(STR_SV_STNAME_MINES))) {
if (CountMapSquareAround(tile, MP_INDUSTRY, IT_COAL_MINE) >= 2 ||
CountMapSquareAround(tile, MP_INDUSTRY, IT_IRON_MINE) >= 2 ||
CountMapSquareAround(tile, MP_INDUSTRY, IT_COPPER_MINE) >= 2 ||
CountMapSquareAround(tile, MP_INDUSTRY, IT_GOLD_MINE) >= 2 ||
CountMapSquareAround(tile, MP_INDUSTRY, IT_DIAMOND_MINE) >= 2) {
found = M(STR_SV_STNAME_MINES);
goto done;
}
}
/* check close enough to town to get central as name? */
if (DistanceMax(tile,t->xy) < 8) {
found = M(STR_SV_STNAME);
if (HASBIT(free_names, M(STR_SV_STNAME))) goto done;
found = M(STR_SV_STNAME_CENTRAL);
if (HASBIT(free_names, M(STR_SV_STNAME_CENTRAL))) goto done;
}
/* Check lakeside */
if (HASBIT(free_names, M(STR_SV_STNAME_LAKESIDE)) &&
DistanceFromEdge(tile) < 20 &&
CountMapSquareAround(tile, MP_WATER, 0) >= 5) {
found = M(STR_SV_STNAME_LAKESIDE);
goto done;
}
/* Check woods */
if (HASBIT(free_names, M(STR_SV_STNAME_WOODS)) && (
CountMapSquareAround(tile, MP_TREES, 0) >= 8 ||
CountMapSquareAround(tile, MP_INDUSTRY, IT_FOREST) >= 2)
) {
found = _opt.landscape == LT_DESERT ?
M(STR_SV_STNAME_FOREST) : M(STR_SV_STNAME_WOODS);
goto done;
}
/* check elevation compared to town */
z = GetTileZ(tile);
z2 = GetTileZ(t->xy);
if (z < z2) {
found = M(STR_SV_STNAME_VALLEY);
if (HASBIT(free_names, M(STR_SV_STNAME_VALLEY))) goto done;
} else if (z > z2) {
found = M(STR_SV_STNAME_HEIGHTS);
if (HASBIT(free_names, M(STR_SV_STNAME_HEIGHTS))) goto done;
}
/* check direction compared to town */
{
static const int8 _direction_and_table[] = {
~( (1<<M(STR_SV_STNAME_WEST)) | (1<<M(STR_SV_STNAME_EAST)) | (1<<M(STR_SV_STNAME_NORTH)) ),
~( (1<<M(STR_SV_STNAME_SOUTH)) | (1<<M(STR_SV_STNAME_WEST)) | (1<<M(STR_SV_STNAME_NORTH)) ),
~( (1<<M(STR_SV_STNAME_SOUTH)) | (1<<M(STR_SV_STNAME_EAST)) | (1<<M(STR_SV_STNAME_NORTH)) ),
~( (1<<M(STR_SV_STNAME_SOUTH)) | (1<<M(STR_SV_STNAME_WEST)) | (1<<M(STR_SV_STNAME_EAST)) ),
};
free_names &= _direction_and_table[
(TileX(tile) < TileX(t->xy)) +
(TileY(tile) < TileY(t->xy)) * 2];
}
tmp = free_names & ((1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<6)|(1<<7)|(1<<12)|(1<<26)|(1<<27)|(1<<28)|(1<<29)|(1<<30));
if (tmp == 0) {
++STNUM;
return false;
}
found = FindFirstBit(tmp);
done:
st->string_id = found + STR_SV_STNAME;
++STNUM;
return true;
};
else { if (STNUM <=30) {
return false;
}
else (STNUM >=30){
st->string_id = 24582 && string_id = 440 + STNUM;
++STNUM;
}
}
Code: Select all
static bool GenerateStationName(Station *st, TileIndex tile, int flag)
{ static unsigned char STNUM;
STNUM = 0; //neccessary to have unlimited station names
} //end of Function
if (STNUM == 0) {
what i ment is you had a "}" ending the function so it didnt know the rest of the code was included in the GenerateStationName
i fix all the compile errors bar the one at the end of the code where i have added a compment to
Code: Select all
static bool GenerateStationName(Station *st, TileIndex tile, int flag)
{ static unsigned char STNUM;
STNUM = 0; //neccessary to have unlimited station names
if (STNUM == 0) {
static const uint32 _gen_station_name_bits[] = {
0, /* 0 */
1 << M(STR_SV_STNAME_AIRPORT), /* 1 */
1 << M(STR_SV_STNAME_OILFIELD), /* 2 */
1 << M(STR_SV_STNAME_DOCKS), /* 3 */
0x1FF << M(STR_SV_STNAME_BUOY_1), /* 4 */
1 << M(STR_SV_STNAME_HELIPORT), /* 5 */
};
Town *t = st->town;
uint32 free_names = (uint32)-1;
int found;
uint z,z2;
unsigned long tmp;
{
Station *s;
FOR_ALL_STATIONS(s) {
if (s != st && s->xy != 0 && s->town==t) {
uint str = M(s->string_id);
if (str <= 0x20) {
if (str == M(STR_SV_STNAME_FOREST))
str = M(STR_SV_STNAME_WOODS);
CLRBIT(free_names, str);
}
}
}
}
/* check default names */
tmp = free_names & _gen_station_name_bits[flag];
if (tmp != 0) {
found = FindFirstBit(tmp);
goto done;
}
/* check mine? */
if (HASBIT(free_names, M(STR_SV_STNAME_MINES))) {
if (CountMapSquareAround(tile, MP_INDUSTRY, IT_COAL_MINE) >= 2 ||
CountMapSquareAround(tile, MP_INDUSTRY, IT_IRON_MINE) >= 2 ||
CountMapSquareAround(tile, MP_INDUSTRY, IT_COPPER_MINE) >= 2 ||
CountMapSquareAround(tile, MP_INDUSTRY, IT_GOLD_MINE) >= 2 ||
CountMapSquareAround(tile, MP_INDUSTRY, IT_DIAMOND_MINE) >= 2) {
found = M(STR_SV_STNAME_MINES);
goto done;
}
}
/* check close enough to town to get central as name? */
if (DistanceMax(tile,t->xy) < 8) {
found = M(STR_SV_STNAME);
if (HASBIT(free_names, M(STR_SV_STNAME))) goto done;
found = M(STR_SV_STNAME_CENTRAL);
if (HASBIT(free_names, M(STR_SV_STNAME_CENTRAL))) goto done;
}
/* Check lakeside */
if (HASBIT(free_names, M(STR_SV_STNAME_LAKESIDE)) &&
DistanceFromEdge(tile) < 20 &&
CountMapSquareAround(tile, MP_WATER, 0) >= 5) {
found = M(STR_SV_STNAME_LAKESIDE);
goto done;
}
/* Check woods */
if (HASBIT(free_names, M(STR_SV_STNAME_WOODS)) && (
CountMapSquareAround(tile, MP_TREES, 0) >= 8 ||
CountMapSquareAround(tile, MP_INDUSTRY, IT_FOREST) >= 2)
) {
found = _opt.landscape == LT_DESERT ?
M(STR_SV_STNAME_FOREST) : M(STR_SV_STNAME_WOODS);
goto done;
}
/* check elevation compared to town */
z = GetTileZ(tile);
z2 = GetTileZ(t->xy);
if (z < z2) {
found = M(STR_SV_STNAME_VALLEY);
if (HASBIT(free_names, M(STR_SV_STNAME_VALLEY))) goto done;
} else if (z > z2) {
found = M(STR_SV_STNAME_HEIGHTS);
if (HASBIT(free_names, M(STR_SV_STNAME_HEIGHTS))) goto done;
}
/* check direction compared to town */
{
static const int8 _direction_and_table[] = {
~( (1<<M(STR_SV_STNAME_WEST)) | (1<<M(STR_SV_STNAME_EAST)) | (1<<M(STR_SV_STNAME_NORTH)) ),
~( (1<<M(STR_SV_STNAME_SOUTH)) | (1<<M(STR_SV_STNAME_WEST)) | (1<<M(STR_SV_STNAME_NORTH)) ),
~( (1<<M(STR_SV_STNAME_SOUTH)) | (1<<M(STR_SV_STNAME_EAST)) | (1<<M(STR_SV_STNAME_NORTH)) ),
~( (1<<M(STR_SV_STNAME_SOUTH)) | (1<<M(STR_SV_STNAME_WEST)) | (1<<M(STR_SV_STNAME_EAST)) ),
};
free_names &= _direction_and_table[
(TileX(tile) < TileX(t->xy)) +
(TileY(tile) < TileY(t->xy)) * 2];
}
tmp = free_names & ((1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<6)|(1<<7)|(1<<12)|(1<<26)|(1<<27)|(1<<28)|(1<<29)|(1<<30));
if (tmp == 0) {
++STNUM;
return false;
}
else {
if (STNUM <=30) {
return false;
}
else (STNUM >=30){
st->string_id = 24582 && string_id = 440 + STNUM;
// have no idea what happening there
// but string_id is a preset phrase you can ither make more
// strings or or store two strings and display them both or
// display a number after the string like trains do
++STNUM;
}
found = FindFirstBit(tmp);
done:
st->string_id = found + STR_SV_STNAME;
++STNUM;
return true;
};
}
}
i fix all the compile errors bar the one at the end of the code where i have added a compment to
Code: Select all
st->string_id = 24582 && string_id = 440 + STNUM;
The && is a logical AND operator and should not be used that way (IMO).
those two lines should look like something like this:
Code: Select all
st->string_id = STR_NAME_FOR_DUNNO;
string_id = STR_NAME_FOR_SOMETHING_OTHER + stnum;
And if you have errors, write them down here. So that we can help here without having to patch our workingspace. And last but not least: create a damn diff file. That helps us much more to help you if there are serious problems.
Code: Select all
else (STNUM >=30){
Code: Select all
}
else {
if (STNUM <=30) {
return false;
}
Code: Select all
} else if (stnum <= 30) {
return false;
}
So, when two companies both have a station named "Foo City Central", and one buys the other out, what happens? Does the one company now have two stations named "Foo City Central"? Does the buyout fail? Does something else happen?Salvo_guy wrote:well the idea was just to have an extend "list" of station names... but being able to have the same names with different companies would b good...
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
currently it is just a coded "error" because if you compile my last patch... you'll notice that you can have 100 stations called the same thing...
the only thing that matters really is the station id (which is what the computer actually looks at...) you only see a name not an ID number
so you can have every station using the same name it would just get very confusing
the only thing that matters really is the station id (which is what the computer actually looks at...) you only see a name not an ID number
so you can have every station using the same name it would just get very confusing
so i've revised my code... but getting one error...
the patch displays
i'm using mainly strings to do this...
help?
the patch displays
Code: Select all
{"Town Name" +Station #"random constantly changing number"}
help?
Who is online
Users browsing this forum: No registered users and 16 guests