mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 22:28:56 +00:00
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
This commit is contained in:
parent
80ef389080
commit
dcd510c81f
144
src/namegen.cpp
144
src/namegen.cpp
@ -1,5 +1,7 @@
|
||||
/* $Id$ */
|
||||
|
||||
/** @file namegen.cpp */
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "openttd.h"
|
||||
#include "debug.h"
|
||||
@ -41,21 +43,21 @@ static byte MakeEnglishOriginalTownName(char *buf, uint32 seed, const char *last
|
||||
{
|
||||
int i;
|
||||
|
||||
//null terminates the string for strcat
|
||||
/* null terminates the string for strcat */
|
||||
strecpy(buf, "", last);
|
||||
|
||||
// optional first segment
|
||||
/* optional first segment */
|
||||
i = SeedChanceBias(0, lengthof(name_original_english_1), seed, 50);
|
||||
if (i >= 0)
|
||||
strecat(buf, name_original_english_1[i], last);
|
||||
|
||||
//mandatory middle segments
|
||||
/* mandatory middle segments */
|
||||
strecat(buf, name_original_english_2[SeedChance(4, lengthof(name_original_english_2), seed)], last);
|
||||
strecat(buf, name_original_english_3[SeedChance(7, lengthof(name_original_english_3), seed)], last);
|
||||
strecat(buf, name_original_english_4[SeedChance(10, lengthof(name_original_english_4), seed)], last);
|
||||
strecat(buf, name_original_english_5[SeedChance(13, lengthof(name_original_english_5), seed)], last);
|
||||
|
||||
//optional last segment
|
||||
/* optional last segment */
|
||||
i = SeedChanceBias(15, lengthof(name_original_english_6), seed, 60);
|
||||
if (i >= 0)
|
||||
strecat(buf, name_original_english_6[i], last);
|
||||
@ -82,10 +84,10 @@ static byte MakeEnglishAdditionalTownName(char *buf, uint32 seed, const char *la
|
||||
{
|
||||
int i;
|
||||
|
||||
//null terminates the string for strcat
|
||||
/* null terminates the string for strcat */
|
||||
strecpy(buf, "", last);
|
||||
|
||||
// optional first segment
|
||||
/* optional first segment */
|
||||
i = SeedChanceBias(0, lengthof(name_additional_english_prefix), seed, 50);
|
||||
if (i >= 0)
|
||||
strecat(buf,name_additional_english_prefix[i], last);
|
||||
@ -104,7 +106,7 @@ static byte MakeEnglishAdditionalTownName(char *buf, uint32 seed, const char *la
|
||||
|
||||
strecat(buf, name_additional_english_2[SeedChance(14, lengthof(name_additional_english_2), seed)], last);
|
||||
|
||||
//optional last segment
|
||||
/* optional last segment */
|
||||
i = SeedChanceBias(15, lengthof(name_additional_english_3), seed, 60);
|
||||
if (i >= 0)
|
||||
strecat(buf, name_additional_english_3[i], last);
|
||||
@ -128,32 +130,32 @@ static byte MakeAustrianTownName(char *buf, uint32 seed, const char *last)
|
||||
int i, j = 0;
|
||||
strecpy(buf, "", last);
|
||||
|
||||
// Bad, Maria, Gross, ...
|
||||
/* Bad, Maria, Gross, ... */
|
||||
i = SeedChanceBias(0, lengthof(name_austrian_a1), seed, 15);
|
||||
if (i >= 0) strecat(buf, name_austrian_a1[i], last);
|
||||
|
||||
i = SeedChance(4, 6, seed);
|
||||
if (i >= 4) {
|
||||
// Kaisers-kirchen
|
||||
/* Kaisers-kirchen */
|
||||
strecat(buf, name_austrian_a2[SeedChance( 7, lengthof(name_austrian_a2), seed)], last);
|
||||
strecat(buf, name_austrian_a3[SeedChance(13, lengthof(name_austrian_a3), seed)], last);
|
||||
} else if (i >= 2) {
|
||||
// St. Johann
|
||||
/* St. Johann */
|
||||
strecat(buf, name_austrian_a5[SeedChance( 7, lengthof(name_austrian_a5), seed)], last);
|
||||
strecat(buf, name_austrian_a6[SeedChance( 9, lengthof(name_austrian_a6), seed)], last);
|
||||
j = 1; // More likely to have a " an der " or " am "
|
||||
} else {
|
||||
// Zell
|
||||
/* Zell */
|
||||
strecat(buf, name_austrian_a4[SeedChance( 7, lengthof(name_austrian_a4), seed)], last);
|
||||
}
|
||||
|
||||
i = SeedChance(1, 6, seed);
|
||||
if (i >= 4 - j) {
|
||||
// an der Donau (rivers)
|
||||
/* an der Donau (rivers) */
|
||||
strecat(buf, name_austrian_f1[SeedChance(4, lengthof(name_austrian_f1), seed)], last);
|
||||
strecat(buf, name_austrian_f2[SeedChance(5, lengthof(name_austrian_f2), seed)], last);
|
||||
} else if (i >= 2 - j) {
|
||||
// am Dachstein (mountains)
|
||||
/* am Dachstein (mountains) */
|
||||
strecat(buf, name_austrian_b1[SeedChance(4, lengthof(name_austrian_b1), seed)], last);
|
||||
strecat(buf, name_austrian_b2[SeedChance(5, lengthof(name_austrian_b2), seed)], last);
|
||||
}
|
||||
@ -166,18 +168,18 @@ static byte MakeGermanTownName(char *buf, uint32 seed, const char *last)
|
||||
uint i;
|
||||
uint seed_derivative;
|
||||
|
||||
//null terminates the string for strcat
|
||||
/* null terminates the string for strcat */
|
||||
strecpy(buf, "", last);
|
||||
|
||||
seed_derivative = SeedChance(7, 28, seed);
|
||||
|
||||
//optional prefix
|
||||
/* optional prefix */
|
||||
if (seed_derivative == 12 || seed_derivative == 19) {
|
||||
i = SeedChance(2, lengthof(name_german_pre), seed);
|
||||
strecat(buf,name_german_pre[i], last);
|
||||
}
|
||||
|
||||
// mandatory middle segments including option of hardcoded name
|
||||
/* mandatory middle segments including option of hardcoded name */
|
||||
i = SeedChance(3, lengthof(name_german_real) + lengthof(name_german_1), seed);
|
||||
if (i < lengthof(name_german_real)) {
|
||||
strecat(buf,name_german_real[i], last);
|
||||
@ -188,7 +190,7 @@ static byte MakeGermanTownName(char *buf, uint32 seed, const char *last)
|
||||
strecat(buf, name_german_2[i], last);
|
||||
}
|
||||
|
||||
// optional suffix
|
||||
/* optional suffix */
|
||||
if (seed_derivative == 24) {
|
||||
i = SeedChance(9,
|
||||
lengthof(name_german_4_an_der) + lengthof(name_german_4_am), seed);
|
||||
@ -226,15 +228,15 @@ static byte MakeSwedishTownName(char *buf, uint32 seed, const char *last)
|
||||
{
|
||||
int i;
|
||||
|
||||
//null terminates the string for strcat
|
||||
/* null terminates the string for strcat */
|
||||
strecpy(buf, "", last);
|
||||
|
||||
// optional first segment
|
||||
/* optional first segment */
|
||||
i = SeedChanceBias(0, lengthof(name_swedish_1), seed, 50);
|
||||
if (i >= 0)
|
||||
strecat(buf, name_swedish_1[i], last);
|
||||
|
||||
// mandatory middle segments including option of hardcoded name
|
||||
/* mandatory middle segments including option of hardcoded name */
|
||||
if (SeedChance(4, 5, seed) >= 3) {
|
||||
strecat(buf, name_swedish_2[SeedChance( 7, lengthof(name_swedish_2), seed)], last);
|
||||
} else {
|
||||
@ -252,15 +254,15 @@ static byte MakeDutchTownName(char *buf, uint32 seed, const char *last)
|
||||
{
|
||||
int i;
|
||||
|
||||
//null terminates the string for strcat
|
||||
/* null terminates the string for strcat */
|
||||
strecpy(buf, "", last);
|
||||
|
||||
// optional first segment
|
||||
/* optional first segment */
|
||||
i = SeedChanceBias(0, lengthof(name_dutch_1), seed, 50);
|
||||
if (i >= 0)
|
||||
strecat(buf, name_dutch_1[i], last);
|
||||
|
||||
// mandatory middle segments including option of hardcoded name
|
||||
/* mandatory middle segments including option of hardcoded name */
|
||||
if (SeedChance(6, 9, seed) > 4) {
|
||||
strecat(buf, name_dutch_2[SeedChance( 9, lengthof(name_dutch_2), seed)], last);
|
||||
} else {
|
||||
@ -274,16 +276,16 @@ static byte MakeDutchTownName(char *buf, uint32 seed, const char *last)
|
||||
|
||||
static byte MakeFinnishTownName(char *buf, uint32 seed, const char *last)
|
||||
{
|
||||
//null terminates the string for strcat
|
||||
/* null terminates the string for strcat */
|
||||
strecpy(buf, "", last);
|
||||
|
||||
// Select randomly if town name should consists of one or two parts.
|
||||
/* Select randomly if town name should consists of one or two parts. */
|
||||
if (SeedChance(0, 15, seed) >= 10) {
|
||||
strecat(buf, name_finnish_real[SeedChance(2, lengthof(name_finnish_real), seed)], last);
|
||||
} else if (SeedChance(0, 15, seed) >= 5) {
|
||||
// A two-part name by combining one of name_finnish_1 + "la"/"lä"
|
||||
// The reason for not having the contents of name_finnish_{1,2} in the same table is
|
||||
// that the ones in name_finnish_2 are not good for this purpose.
|
||||
/* A two-part name by combining one of name_finnish_1 + "la"/"lä"
|
||||
* The reason for not having the contents of name_finnish_{1,2} in the same table is
|
||||
* that the ones in name_finnish_2 are not good for this purpose. */
|
||||
uint sel = SeedChance( 0, lengthof(name_finnish_1), seed);
|
||||
char *end;
|
||||
strecat(buf, name_finnish_1[sel], last);
|
||||
@ -298,8 +300,8 @@ static byte MakeFinnishTownName(char *buf, uint32 seed, const char *last)
|
||||
strecat(buf, "lä", last);
|
||||
}
|
||||
} else {
|
||||
// A two-part name by combining one of name_finnish_{1,2} + name_finnish_3.
|
||||
// Why aren't name_finnish_{1,2} just one table? See above.
|
||||
/* A two-part name by combining one of name_finnish_{1,2} + name_finnish_3.
|
||||
* Why aren't name_finnish_{1,2} just one table? See above. */
|
||||
uint sel = SeedChance(2,
|
||||
lengthof(name_finnish_1) + lengthof(name_finnish_2), seed);
|
||||
if (sel >= lengthof(name_finnish_1)) {
|
||||
@ -318,10 +320,10 @@ static byte MakePolishTownName(char *buf, uint32 seed, const char *last)
|
||||
uint i;
|
||||
uint j;
|
||||
|
||||
//null terminates the string for strcat
|
||||
/* null terminates the string for strcat */
|
||||
strecpy(buf, "", last);
|
||||
|
||||
// optional first segment
|
||||
/* optional first segment */
|
||||
i = SeedChance(0,
|
||||
lengthof(name_polish_2_o) + lengthof(name_polish_2_m) +
|
||||
lengthof(name_polish_2_f) + lengthof(name_polish_2_n),
|
||||
@ -374,13 +376,13 @@ static byte MakeCzechTownName(char *buf, uint32 seed, const char *last)
|
||||
CzechChoose choose;
|
||||
CzechAllow allow;
|
||||
|
||||
// 1:3 chance to use a real name.
|
||||
/* 1:3 chance to use a real name. */
|
||||
if (SeedModChance(0, 4, seed) == 0) {
|
||||
strecpy(buf, name_czech_real[SeedModChance(4, lengthof(name_czech_real), seed)], last);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// NUL terminates the string for strcat()
|
||||
/* NUL terminates the string for strcat() */
|
||||
strecpy(buf, "", last);
|
||||
|
||||
prob_tails = SeedModChance(2, 32, seed);
|
||||
@ -389,12 +391,12 @@ static byte MakeCzechTownName(char *buf, uint32 seed, const char *last)
|
||||
|
||||
if (do_prefix) prefix = SeedModChance(5, lengthof(name_czech_adj) * 12, seed) / 12;
|
||||
if (do_suffix) suffix = SeedModChance(7, lengthof(name_czech_suffix), seed);
|
||||
// 3:1 chance 3:1 to use dynamic substantive
|
||||
/* 3:1 chance 3:1 to use dynamic substantive */
|
||||
stem = SeedModChance(9,
|
||||
lengthof(name_czech_subst_full) + 3 * lengthof(name_czech_subst_stem),
|
||||
seed);
|
||||
if (stem < lengthof(name_czech_subst_full)) {
|
||||
// That was easy!
|
||||
/* That was easy! */
|
||||
dynamic_subst = false;
|
||||
gender = name_czech_subst_full[stem].gender;
|
||||
choose = name_czech_subst_full[stem].choose;
|
||||
@ -404,7 +406,7 @@ static byte MakeCzechTownName(char *buf, uint32 seed, const char *last)
|
||||
int ending_start = -1, ending_stop = -1;
|
||||
int i;
|
||||
|
||||
// Load the substantive
|
||||
/* Load the substantive */
|
||||
dynamic_subst = true;
|
||||
stem -= lengthof(name_czech_subst_full);
|
||||
stem %= lengthof(name_czech_subst_stem);
|
||||
@ -412,15 +414,15 @@ static byte MakeCzechTownName(char *buf, uint32 seed, const char *last)
|
||||
choose = name_czech_subst_stem[stem].choose;
|
||||
allow = name_czech_subst_stem[stem].allow;
|
||||
|
||||
// Load the postfix (1:1 chance that a postfix will be inserted)
|
||||
/* Load the postfix (1:1 chance that a postfix will be inserted) */
|
||||
postfix = SeedModChance(14, lengthof(name_czech_subst_postfix) * 2, seed);
|
||||
|
||||
if (choose & CZC_POSTFIX) {
|
||||
// Always get a real postfix.
|
||||
/* Always get a real postfix. */
|
||||
postfix %= lengthof(name_czech_subst_postfix);
|
||||
}
|
||||
if (choose & CZC_NOPOSTFIX) {
|
||||
// Always drop a postfix.
|
||||
/* Always drop a postfix. */
|
||||
postfix += lengthof(name_czech_subst_postfix);
|
||||
}
|
||||
if (postfix < lengthof(name_czech_subst_postfix)) {
|
||||
@ -429,7 +431,7 @@ static byte MakeCzechTownName(char *buf, uint32 seed, const char *last)
|
||||
choose |= CZC_NOPOSTFIX;
|
||||
}
|
||||
|
||||
// Localize the array segment containing a good gender
|
||||
/* Localize the array segment containing a good gender */
|
||||
for (ending = 0; ending < (int) lengthof(name_czech_subst_ending); ending++) {
|
||||
const CzechNameSubst *e = &name_czech_subst_ending[ending];
|
||||
|
||||
@ -445,11 +447,11 @@ static byte MakeCzechTownName(char *buf, uint32 seed, const char *last)
|
||||
}
|
||||
}
|
||||
if (ending_stop < 0) {
|
||||
// Whoa. All the endings matched.
|
||||
/* Whoa. All the endings matched. */
|
||||
ending_stop = ending - 1;
|
||||
}
|
||||
|
||||
// Make a sequential map of the items with good mask
|
||||
/* Make a sequential map of the items with good mask */
|
||||
i = 0;
|
||||
for (ending = ending_start; ending <= ending_stop; ending++) {
|
||||
const CzechNameSubst *e = &name_czech_subst_ending[ending];
|
||||
@ -459,20 +461,20 @@ static byte MakeCzechTownName(char *buf, uint32 seed, const char *last)
|
||||
}
|
||||
assert(i > 0);
|
||||
|
||||
// Load the ending
|
||||
/* Load the ending */
|
||||
ending = map[SeedModChance(16, i, seed)];
|
||||
// Override possible CZG_*FREE; this must be a real gender,
|
||||
// otherwise we get overflow when modifying the adjectivum.
|
||||
/* Override possible CZG_*FREE; this must be a real gender,
|
||||
* otherwise we get overflow when modifying the adjectivum. */
|
||||
gender = name_czech_subst_ending[ending].gender;
|
||||
assert(gender != CZG_FREE && gender != CZG_NFREE);
|
||||
}
|
||||
|
||||
if (do_prefix && (name_czech_adj[prefix].choose & choose) != choose) {
|
||||
// Throw away non-matching prefix.
|
||||
/* Throw away non-matching prefix. */
|
||||
do_prefix = false;
|
||||
}
|
||||
|
||||
// Now finally construct the name
|
||||
/* Now finally construct the name */
|
||||
|
||||
if (do_prefix) {
|
||||
CzechPattern pattern = name_czech_adj[prefix].pattern;
|
||||
@ -505,7 +507,7 @@ static byte MakeCzechTownName(char *buf, uint32 seed, const char *last)
|
||||
endlen = strlen(endstr);
|
||||
assert(postlen > 0 && endlen > 0);
|
||||
|
||||
// Kill the "avava" and "Jananna"-like cases
|
||||
/* Kill the "avava" and "Jananna"-like cases */
|
||||
if (postlen < 2 || postlen > endlen || (
|
||||
(poststr[1] != 'v' || poststr[1] != endstr[1]) &&
|
||||
poststr[2] != endstr[1])
|
||||
@ -514,7 +516,7 @@ static byte MakeCzechTownName(char *buf, uint32 seed, const char *last)
|
||||
strecat(buf, poststr, last);
|
||||
buflen = strlen(buf);
|
||||
|
||||
// k-i -> c-i, h-i -> z-i
|
||||
/* k-i -> c-i, h-i -> z-i */
|
||||
if (endstr[0] == 'i') {
|
||||
switch (buf[buflen - 1]) {
|
||||
case 'k': buf[buflen - 1] = 'c'; break;
|
||||
@ -553,15 +555,15 @@ static byte MakeNorwegianTownName(char *buf, uint32 seed, const char *last)
|
||||
{
|
||||
strecpy(buf, "", last);
|
||||
|
||||
// Use first 4 bit from seed to decide whether or not this town should
|
||||
// have a real name 3/16 chance. Bit 0-3
|
||||
/* Use first 4 bit from seed to decide whether or not this town should
|
||||
* have a real name 3/16 chance. Bit 0-3 */
|
||||
if (SeedChance(0, 15, seed) < 3) {
|
||||
// Use 7bit for the realname table index. Bit 4-10
|
||||
/* Use 7bit for the realname table index. Bit 4-10 */
|
||||
strecat(buf, name_norwegian_real[SeedChance(4, lengthof(name_norwegian_real), seed)], last);
|
||||
} else {
|
||||
// Use 7bit for the first fake part. Bit 4-10
|
||||
/* Use 7bit for the first fake part. Bit 4-10 */
|
||||
strecat(buf, name_norwegian_1[SeedChance(4, lengthof(name_norwegian_1), seed)], last);
|
||||
// Use 7bit for the last fake part. Bit 11-17
|
||||
/* Use 7bit for the last fake part. Bit 11-17 */
|
||||
strecat(buf, name_norwegian_2[SeedChance(11, lengthof(name_norwegian_2), seed)], last);
|
||||
}
|
||||
|
||||
@ -572,22 +574,22 @@ static byte MakeHungarianTownName(char *buf, uint32 seed, const char *last)
|
||||
{
|
||||
uint i;
|
||||
|
||||
//null terminates the string for strcat
|
||||
/* null terminates the string for strcat */
|
||||
strecpy(buf, "", last);
|
||||
|
||||
if (SeedChance(12, 15, seed) < 3) {
|
||||
strecat(buf, name_hungarian_real[SeedChance(0, lengthof(name_hungarian_real), seed)], last);
|
||||
} else {
|
||||
// optional first segment
|
||||
/* optional first segment */
|
||||
i = SeedChance(3, lengthof(name_hungarian_1) * 3, seed);
|
||||
if (i < lengthof(name_hungarian_1))
|
||||
strecat(buf, name_hungarian_1[i], last);
|
||||
|
||||
// mandatory middle segments
|
||||
/* mandatory middle segments */
|
||||
strecat(buf, name_hungarian_2[SeedChance(3, lengthof(name_hungarian_2), seed)], last);
|
||||
strecat(buf, name_hungarian_3[SeedChance(6, lengthof(name_hungarian_3), seed)], last);
|
||||
|
||||
// optional last segment
|
||||
/* optional last segment */
|
||||
i = SeedChance(10, lengthof(name_hungarian_4) * 3, seed);
|
||||
if (i < lengthof(name_hungarian_4)) {
|
||||
strecat(buf, name_hungarian_4[i], last);
|
||||
@ -607,15 +609,15 @@ static byte MakeDanishTownName(char *buf, uint32 seed, const char *last)
|
||||
{
|
||||
int i;
|
||||
|
||||
// null terminates the string for strcat
|
||||
/* null terminates the string for strcat */
|
||||
strecpy(buf, "", last);
|
||||
|
||||
// optional first segment
|
||||
/* optional first segment */
|
||||
i = SeedChanceBias(0, lengthof(name_danish_1), seed, 50);
|
||||
if (i >= 0)
|
||||
strecat(buf, name_danish_1[i], last);
|
||||
|
||||
// middle segments removed as this algorithm seems to create much more realistic names
|
||||
/* middle segments removed as this algorithm seems to create much more realistic names */
|
||||
strecat(buf, name_danish_2[SeedChance( 7, lengthof(name_danish_2), seed)], last);
|
||||
strecat(buf, name_danish_3[SeedChance(16, lengthof(name_danish_3), seed)], last);
|
||||
|
||||
@ -626,16 +628,16 @@ static byte MakeTurkishTownName(char *buf, uint32 seed, const char *last)
|
||||
{
|
||||
uint i;
|
||||
|
||||
// null terminates the string for strcat
|
||||
/* null terminates the string for strcat */
|
||||
strecpy(buf, "", last);
|
||||
|
||||
if ((i = SeedModChance(0, 5, seed)) == 0) {
|
||||
strecat(buf, name_turkish_prefix[SeedModChance( 2, lengthof(name_turkish_prefix), seed)], last);
|
||||
|
||||
// middle segment
|
||||
/* middle segment */
|
||||
strecat(buf, name_turkish_middle[SeedModChance( 4, lengthof(name_turkish_middle), seed)], last);
|
||||
|
||||
// optional suffix
|
||||
/* optional suffix */
|
||||
if (SeedModChance(0, 7, seed) == 0) {
|
||||
strecat(buf, name_turkish_suffix[SeedModChance( 10, lengthof(name_turkish_suffix), seed)], last);
|
||||
}
|
||||
@ -757,30 +759,30 @@ TownNameGenerator * const _town_name_generators[] =
|
||||
MakeCatalanTownName,
|
||||
};
|
||||
|
||||
// DO WE NEED THIS ANY MORE?
|
||||
/* DO WE NEED THIS ANY MORE? */
|
||||
#define FIXNUM(x, y, z) (((((x) << 16) / (y)) + 1) << z)
|
||||
|
||||
uint32 GetOldTownName(uint32 townnameparts, byte old_town_name_type)
|
||||
{
|
||||
switch (old_town_name_type) {
|
||||
case 0: case 3: /* English, American */
|
||||
case 0: case 3: // English, American
|
||||
/* Already OK */
|
||||
return townnameparts;
|
||||
|
||||
case 1: /* French */
|
||||
case 1: // French
|
||||
/* For some reason 86 needs to be subtracted from townnameparts
|
||||
* 0000 0000 0000 0000 0000 0000 1111 1111 */
|
||||
return FIXNUM(townnameparts - 86, lengthof(name_french_real), 0);
|
||||
|
||||
case 2: /* German */
|
||||
case 2: // German
|
||||
DEBUG(misc, 0, "German Townnames are buggy (%d)", townnameparts);
|
||||
return townnameparts;
|
||||
|
||||
case 4: /* Latin-American */
|
||||
case 4: // Latin-American
|
||||
/* 0000 0000 0000 0000 0000 0000 1111 1111 */
|
||||
return FIXNUM(townnameparts, lengthof(name_spanish_real), 0);
|
||||
|
||||
case 5: /* Silly */
|
||||
case 5: // Silly
|
||||
/* NUM_SILLY_1 - lower 16 bits
|
||||
* NUM_SILLY_2 - upper 16 bits without leading 1 (first 8 bytes)
|
||||
* 1000 0000 2222 2222 0000 0000 1111 1111 */
|
||||
|
@ -1,5 +1,7 @@
|
||||
/* $Id$ */
|
||||
|
||||
/** @file namegen.h */
|
||||
|
||||
#ifndef NAMEGEN_H
|
||||
#define NAMEGEN_H
|
||||
|
||||
|
414
src/newgrf.cpp
414
src/newgrf.cpp
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,7 @@
|
||||
/* $Id$ */
|
||||
|
||||
/** @file newgrf.h */
|
||||
|
||||
#ifndef NEWGRF_H
|
||||
#define NEWGRF_H
|
||||
|
||||
@ -60,7 +62,7 @@ struct GRFFile {
|
||||
HouseSpec **housespec;
|
||||
|
||||
uint32 param[0x80];
|
||||
uint param_end; /// one more than the highest set parameter
|
||||
uint param_end; ///< one more than the highest set parameter
|
||||
|
||||
GRFLabel *label; ///< Pointer to the first label. This is a linked list, not an array.
|
||||
|
||||
@ -78,7 +80,7 @@ extern bool _have_newhouses;
|
||||
|
||||
void LoadNewGRFFile(GRFConfig *config, uint file_index, GrfLoadingStage stage);
|
||||
void LoadNewGRF(uint load_index, uint file_index);
|
||||
void ReloadNewGRFData(); // in openttd.c
|
||||
void ReloadNewGRFData(); // in openttd.cpp
|
||||
|
||||
void CDECL grfmsg(int severity, const char *str, ...);
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
/* $Id$ */
|
||||
|
||||
/** @file newgrf_cargo.h */
|
||||
|
||||
#ifndef NEWGRF_CARGO_H
|
||||
#define NEWGRF_CARGO_H
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
/* $Id$ */
|
||||
|
||||
/** @file newgfr_config.cpp */
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "openttd.h"
|
||||
#include "functions.h"
|
||||
@ -481,3 +483,4 @@ extern const ChunkHandler _newgrf_chunk_handlers[] = {
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
/* $Id$ */
|
||||
|
||||
/** @file newgrf_config.h */
|
||||
|
||||
#ifndef NEWGRF_CONFIG_H
|
||||
#define NEWGRF_CONFIG_H
|
||||
|
||||
@ -80,7 +82,7 @@ GRFListCompatibility IsGoodGRFConfigList();
|
||||
bool FillGRFDetails(GRFConfig *config, bool is_static);
|
||||
char *GRFBuildParamList(char *dst, const GRFConfig *c, const char *last);
|
||||
|
||||
/* In newgrf_gui.c */
|
||||
/* In newgrf_gui.cpp */
|
||||
void ShowNewGRFSettings(bool editable, bool show_params, bool exec_changes, GRFConfig **config);
|
||||
|
||||
#ifdef ENABLE_NETWORK
|
||||
|
@ -1,5 +1,7 @@
|
||||
/* $Id$ */
|
||||
|
||||
/** @file newgrf_engine.cpp */
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "openttd.h"
|
||||
#include "variables.h"
|
||||
@ -66,10 +68,10 @@ static const SpriteGroup *GetWagonOverrideSpriteSet(EngineID engine, CargoID car
|
||||
const WagonOverrides *wos = &_engine_wagon_overrides[engine];
|
||||
int i;
|
||||
|
||||
// XXX: This could turn out to be a timesink on profiles. We could
|
||||
// always just dedicate 65535 bytes for an [engine][train] trampoline
|
||||
// for O(1). Or O(logMlogN) and searching binary tree or smt. like
|
||||
// that. --pasky
|
||||
/* XXX: This could turn out to be a timesink on profiles. We could
|
||||
* always just dedicate 65535 bytes for an [engine][train] trampoline
|
||||
* for O(1). Or O(logMlogN) and searching binary tree or smt. like
|
||||
* that. --pasky */
|
||||
|
||||
for (i = 0; i < wos->overrides_count; i++) {
|
||||
const WagonOverride *wo = &wos->overrides[i];
|
||||
@ -260,11 +262,11 @@ static byte MapAircraftMovementState(const Vehicle *v)
|
||||
* to a landing by the hanger of an international airport. */
|
||||
if (amdflag & AMED_SLOWTURN) return AMS_TTDP_FLIGHT_TO_TOWER;
|
||||
|
||||
// The final two conditions apply to helicopters or aircraft.
|
||||
/* Has reached hanger? */
|
||||
/* The final two conditions apply to helicopters or aircraft.
|
||||
* Has reached hanger? */
|
||||
if (amdflag & AMED_EXACTPOS) return AMS_TTDP_HANGAR;
|
||||
|
||||
// Still moving towards hanger.
|
||||
/* Still moving towards hanger. */
|
||||
return AMS_TTDP_TO_HANGAR;
|
||||
|
||||
case TERM1:
|
||||
@ -318,7 +320,7 @@ static byte MapAircraftMovementState(const Vehicle *v)
|
||||
|
||||
case ENDLANDING: // On the runway braking
|
||||
if (amdflag & AMED_BRAKE) return AMS_TTDP_BRAKING;
|
||||
// Landed - moving off runway
|
||||
/* Landed - moving off runway */
|
||||
return AMS_TTDP_TO_INWAY;
|
||||
|
||||
case HELILANDING:
|
||||
@ -393,7 +395,7 @@ static byte MapAircraftMovementAction(const Vehicle *v)
|
||||
case STARTTAKEOFF: // Accelerating down runway
|
||||
case ENDTAKEOFF: // Ascent
|
||||
case HELITAKEOFF:
|
||||
// TODO Need to find which terminal (or hanger) we've come from. How?
|
||||
/* @todo Need to find which terminal (or hanger) we've come from. How? */
|
||||
return AMA_TTDP_PAD1_TO_TAKEOFF;
|
||||
|
||||
case FLYING:
|
||||
@ -403,7 +405,7 @@ static byte MapAircraftMovementAction(const Vehicle *v)
|
||||
case ENDLANDING: // On the runway braking
|
||||
case HELILANDING:
|
||||
case HELIENDLANDING:
|
||||
// TODO Need to check terminal we're landing to. Is it known yet?
|
||||
/* @todo Need to check terminal we're landing to. Is it known yet? */
|
||||
return (v->current_order.type == OT_GOTO_DEPOT) ?
|
||||
AMA_TTDP_LANDING_TO_HANGAR : AMA_TTDP_LANDING_TO_PAD1;
|
||||
|
||||
@ -473,12 +475,12 @@ static uint32 VehicleGetVariable(const ResolverObject *object, byte variable, by
|
||||
if (v == NULL) {
|
||||
/* Vehicle does not exist, so we're in a purchase list */
|
||||
switch (variable) {
|
||||
case 0x43: return _current_player; /* Owner information */
|
||||
case 0x46: return 0; /* Motion counter */
|
||||
case 0x48: return GetEngine(object->u.vehicle.self_type)->flags; /* Vehicle Type Info */
|
||||
case 0xC4: return clamp(_cur_year, ORIGINAL_BASE_YEAR, ORIGINAL_MAX_YEAR) - ORIGINAL_BASE_YEAR; /* Build year */
|
||||
case 0xDA: return INVALID_VEHICLE; /* Next vehicle */
|
||||
case 0x7F: return GetGRFParameter(object->u.vehicle.self_type, parameter); /* Read GRF parameter */
|
||||
case 0x43: return _current_player; // Owner information
|
||||
case 0x46: return 0; // Motion counter
|
||||
case 0x48: return GetEngine(object->u.vehicle.self_type)->flags; // Vehicle Type Info
|
||||
case 0xC4: return clamp(_cur_year, ORIGINAL_BASE_YEAR, ORIGINAL_MAX_YEAR) - ORIGINAL_BASE_YEAR; // Build year
|
||||
case 0xDA: return INVALID_VEHICLE; // Next vehicle
|
||||
case 0x7F: return GetGRFParameter(object->u.vehicle.self_type, parameter); // Read GRF parameter
|
||||
}
|
||||
|
||||
*available = false;
|
||||
@ -487,8 +489,8 @@ static uint32 VehicleGetVariable(const ResolverObject *object, byte variable, by
|
||||
|
||||
/* Calculated vehicle parameters */
|
||||
switch (variable) {
|
||||
case 0x40: /* Get length of consist */
|
||||
case 0x41: /* Get length of same consecutive wagons */
|
||||
case 0x40: // Get length of consist
|
||||
case 0x41: // Get length of same consecutive wagons
|
||||
if (v->type != VEH_TRAIN) return 1;
|
||||
|
||||
{
|
||||
@ -509,7 +511,7 @@ static uint32 VehicleGetVariable(const ResolverObject *object, byte variable, by
|
||||
return chain_before | chain_after << 8 | (chain_before + chain_after + (variable == 0x41)) << 16;
|
||||
}
|
||||
|
||||
case 0x42: { /* Consist cargo information */
|
||||
case 0x42: { // Consist cargo information
|
||||
/* XXX Missing support for common refit cycle and property 25 */
|
||||
const Vehicle *u;
|
||||
byte cargo_classes = 0;
|
||||
@ -541,15 +543,15 @@ static uint32 VehicleGetVariable(const ResolverObject *object, byte variable, by
|
||||
return cargo_classes | (common_cargo_type << 8) | (user_def_data << 24);
|
||||
}
|
||||
|
||||
case 0x43: /* Player information */
|
||||
case 0x43: // Player information
|
||||
return v->owner;
|
||||
|
||||
case 0x44: /* Aircraft information */
|
||||
case 0x44: // Aircraft information
|
||||
if (v->type != VEH_AIRCRAFT) return UINT_MAX;
|
||||
|
||||
{
|
||||
const Vehicle *w = v->next;
|
||||
uint16 altitude = v->z_pos - w->z_pos; /* Aircraft height - shadow height */
|
||||
uint16 altitude = v->z_pos - w->z_pos; // Aircraft height - shadow height
|
||||
byte airporttype;
|
||||
|
||||
switch (GetStation(v->u.air.targetairport)->airport_type) {
|
||||
@ -571,10 +573,10 @@ static uint32 VehicleGetVariable(const ResolverObject *object, byte variable, by
|
||||
return (altitude << 8) | airporttype;
|
||||
}
|
||||
|
||||
case 0x46: /* Motion counter */
|
||||
case 0x46: // Motion counter
|
||||
return v->motion_counter;
|
||||
|
||||
case 0x47: { /* Vehicle cargo info */
|
||||
case 0x47: { // Vehicle cargo info
|
||||
/* Format: ccccwwtt
|
||||
* tt - the cargo type transported by the vehicle,
|
||||
* translated if a translation table has been installed.
|
||||
@ -586,10 +588,10 @@ static uint32 VehicleGetVariable(const ResolverObject *object, byte variable, by
|
||||
return (cs->classes << 16) | (cs->weight << 8) | GetEngineGRF(v->engine_type)->cargo_map[v->cargo_type];
|
||||
}
|
||||
|
||||
case 0x48: return GetEngine(v->engine_type)->flags; /* Vehicle Type Info */
|
||||
case 0x48: return GetEngine(v->engine_type)->flags; // Vehicle Type Info
|
||||
|
||||
/* Variables which use the parameter */
|
||||
case 0x60: /* Count consist's engine ID occurance */
|
||||
case 0x60: // Count consist's engine ID occurance
|
||||
if (v->type != VEH_TRAIN) return v->engine_type == parameter;
|
||||
|
||||
{
|
||||
@ -600,13 +602,13 @@ static uint32 VehicleGetVariable(const ResolverObject *object, byte variable, by
|
||||
return count;
|
||||
}
|
||||
|
||||
case 0x7F: return GetGRFParameter(v->engine_type, parameter); /* Read GRF parameter */
|
||||
case 0x7F: return GetGRFParameter(v->engine_type, parameter); // Read GRF parameter
|
||||
|
||||
case 0xFE:
|
||||
case 0xFF: {
|
||||
uint16 modflags = 0;
|
||||
|
||||
/* TODO: There are some other bits that should be implemented:
|
||||
/* @todo: There are some other bits that should be implemented:
|
||||
* bit 5: Whether the rail vehicle is powered or not (mostly useful for wagons).
|
||||
* bit 6: This is an electrically powered rail vehicle which is running on normal rail.
|
||||
* bit 8: (Maybe?) Toggled whenever the train reverses.
|
||||
@ -992,7 +994,7 @@ static void DoTriggerVehicle(Vehicle *v, VehicleTrigger trigger, byte base_rando
|
||||
void TriggerVehicle(Vehicle *v, VehicleTrigger trigger)
|
||||
{
|
||||
if (trigger == VEHICLE_TRIGGER_DEPOT) {
|
||||
// store that the vehicle entered a depot this tick
|
||||
/* store that the vehicle entered a depot this tick */
|
||||
VehicleEnteredDepotThisTick(v);
|
||||
}
|
||||
|
||||
@ -1020,8 +1022,8 @@ StringID GetCustomEngineName(EngineID engine)
|
||||
return _engine_custom_names[engine] == 0 ? _engine_name_strings[engine] : _engine_custom_names[engine];
|
||||
}
|
||||
|
||||
// Functions for changing the order of vehicle purchase lists
|
||||
// This is currently only implemented for rail vehicles.
|
||||
/* Functions for changing the order of vehicle purchase lists
|
||||
* This is currently only implemented for rail vehicles. */
|
||||
static EngineID _engine_list_order[NUM_TRAIN_ENGINES];
|
||||
static byte _engine_list_position[NUM_TRAIN_ENGINES];
|
||||
|
||||
@ -1066,13 +1068,13 @@ void AlterRailVehListOrder(EngineID engine, EngineID target)
|
||||
|
||||
if (engine == target) return;
|
||||
|
||||
// First, remove our ID from the list.
|
||||
/* First, remove our ID from the list. */
|
||||
for (i = 0; i < NUM_TRAIN_ENGINES - 1; i++) {
|
||||
if (_engine_list_order[i] == engine) moving = true;
|
||||
if (moving) _engine_list_order[i] = _engine_list_order[i + 1];
|
||||
}
|
||||
|
||||
// Now, insert it again, before the target engine.
|
||||
/* Now, insert it again, before the target engine. */
|
||||
for (i = NUM_TRAIN_ENGINES - 1; i > 0; i--) {
|
||||
_engine_list_order[i] = _engine_list_order[i - 1];
|
||||
if (_engine_list_order[i] == target) {
|
||||
@ -1081,7 +1083,7 @@ void AlterRailVehListOrder(EngineID engine, EngineID target)
|
||||
}
|
||||
}
|
||||
|
||||
// Update the engine list position (a reverse of engine list order)
|
||||
/* Update the engine list position (a reverse of engine list order) */
|
||||
for (i = 0; i < NUM_TRAIN_ENGINES; i++) {
|
||||
_engine_list_position[_engine_list_order[i]] = i;
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
/* $Id$ */
|
||||
|
||||
/** @file newgrf_engine.h */
|
||||
|
||||
#ifndef NEWGRF_ENGINE_H
|
||||
#define NEWGRF_ENGINE_H
|
||||
|
||||
@ -7,9 +9,6 @@
|
||||
#include "direction.h"
|
||||
#include "newgrf_cargo.h"
|
||||
|
||||
/** @file newgrf_engine.h
|
||||
*/
|
||||
|
||||
extern int _traininfo_vehicle_pitch;
|
||||
extern int _traininfo_vehicle_width;
|
||||
|
||||
@ -38,11 +37,11 @@ bool UsesWagonOverride(const Vehicle *v);
|
||||
|
||||
enum VehicleTrigger {
|
||||
VEHICLE_TRIGGER_NEW_CARGO = 1,
|
||||
// Externally triggered only for the first vehicle in chain
|
||||
/* Externally triggered only for the first vehicle in chain */
|
||||
VEHICLE_TRIGGER_DEPOT = 2,
|
||||
// Externally triggered only for the first vehicle in chain, only if whole chain is empty
|
||||
/* Externally triggered only for the first vehicle in chain, only if whole chain is empty */
|
||||
VEHICLE_TRIGGER_EMPTY = 4,
|
||||
// Not triggered externally (called for the whole chain if we got NEW_CARGO)
|
||||
/* Not triggered externally (called for the whole chain if we got NEW_CARGO) */
|
||||
VEHICLE_TRIGGER_ANY_NEW_CARGO = 8,
|
||||
};
|
||||
void TriggerVehicle(Vehicle *veh, VehicleTrigger trigger);
|
||||
|
@ -1,5 +1,7 @@
|
||||
/* $Id$ */
|
||||
|
||||
/** @file newgrf_gui.cpp */
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "openttd.h"
|
||||
#include "functions.h"
|
||||
@ -157,7 +159,7 @@ static void NewGRFAddDlgWndProc(Window *w, WindowEvent *e)
|
||||
case WE_CLICK:
|
||||
switch (e->we.click.widget) {
|
||||
case 3: {
|
||||
// Get row...
|
||||
/* Get row... */
|
||||
const GRFConfig *c;
|
||||
uint i = (e->we.click.pt.y - w->widget[3].top) / 10 + w->vscroll.pos;
|
||||
|
||||
@ -167,7 +169,7 @@ static void NewGRFAddDlgWndProc(Window *w, WindowEvent *e)
|
||||
break;
|
||||
}
|
||||
|
||||
case 6: /* Add selection to list */
|
||||
case 6: // Add selection to list
|
||||
if (WP(w, newgrf_add_d).sel != NULL) {
|
||||
const GRFConfig *src = WP(w, newgrf_add_d).sel;
|
||||
GRFConfig **list;
|
||||
@ -196,7 +198,7 @@ static void NewGRFAddDlgWndProc(Window *w, WindowEvent *e)
|
||||
}
|
||||
break;
|
||||
|
||||
case 7: /* Rescan list */
|
||||
case 7: // Rescan list
|
||||
WP(w, newgrf_add_d).sel = NULL;
|
||||
ScanNewGRFFiles();
|
||||
SetWindowDirty(w);
|
||||
@ -376,7 +378,7 @@ static void NewGRFWndProc(Window *w, WindowEvent *e)
|
||||
|
||||
case WE_CLICK:
|
||||
switch (e->we.click.widget) {
|
||||
case SNGRFS_ADD: { /* Add GRF */
|
||||
case SNGRFS_ADD: { // Add GRF
|
||||
GRFConfig **list = WP(w, newgrf_d).list;
|
||||
Window *w;
|
||||
|
||||
@ -388,7 +390,7 @@ static void NewGRFWndProc(Window *w, WindowEvent *e)
|
||||
break;
|
||||
}
|
||||
|
||||
case SNGRFS_REMOVE: { /* Remove GRF */
|
||||
case SNGRFS_REMOVE: { // Remove GRF
|
||||
GRFConfig **pc, *c, *newsel;
|
||||
|
||||
/* Choose the next GRF file to be the selected file */
|
||||
@ -412,7 +414,7 @@ static void NewGRFWndProc(Window *w, WindowEvent *e)
|
||||
break;
|
||||
}
|
||||
|
||||
case SNGRFS_MOVE_UP: { /* Move GRF up */
|
||||
case SNGRFS_MOVE_UP: { // Move GRF up
|
||||
GRFConfig **pc, *c;
|
||||
if (WP(w, newgrf_d).sel == NULL) break;
|
||||
|
||||
@ -428,7 +430,7 @@ static void NewGRFWndProc(Window *w, WindowEvent *e)
|
||||
break;
|
||||
}
|
||||
|
||||
case SNGRFS_MOVE_DOWN: { /* Move GRF down */
|
||||
case SNGRFS_MOVE_DOWN: { // Move GRF down
|
||||
GRFConfig **pc, *c;
|
||||
if (WP(w, newgrf_d).sel == NULL) break;
|
||||
|
||||
@ -444,7 +446,7 @@ static void NewGRFWndProc(Window *w, WindowEvent *e)
|
||||
break;
|
||||
}
|
||||
|
||||
case SNGRFS_FILE_LIST: { /* Select a GRF */
|
||||
case SNGRFS_FILE_LIST: { // Select a GRF
|
||||
GRFConfig *c;
|
||||
uint i = (e->we.click.pt.y - w->widget[SNGRFS_FILE_LIST].top) / 14 + w->vscroll.pos;
|
||||
|
||||
@ -455,7 +457,7 @@ static void NewGRFWndProc(Window *w, WindowEvent *e)
|
||||
break;
|
||||
}
|
||||
|
||||
case SNGRFS_APPLY_CHANGES: /* Apply changes made to GRF list */
|
||||
case SNGRFS_APPLY_CHANGES: // Apply changes made to GRF list
|
||||
if (WP(w, newgrf_d).execute) {
|
||||
ShowQuery(
|
||||
STR_POPUP_CAUTION_CAPTION,
|
||||
@ -468,7 +470,7 @@ static void NewGRFWndProc(Window *w, WindowEvent *e)
|
||||
}
|
||||
break;
|
||||
|
||||
case SNGRFS_SET_PARAMETERS: { /* Edit parameters */
|
||||
case SNGRFS_SET_PARAMETERS: { // Edit parameters
|
||||
char buff[512];
|
||||
if (WP(w, newgrf_d).sel == NULL) break;
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
/* $Id$ */
|
||||
|
||||
/** @file newgrf_sound.cpp */
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "openttd.h"
|
||||
#include "oldpool.h"
|
||||
|
@ -1,5 +1,7 @@
|
||||
/* $Id$ */
|
||||
|
||||
/** @file newgrf_sound.h */
|
||||
|
||||
#ifndef NEWGRF_SOUND_H
|
||||
#define NEWGRF_SOUND_H
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
/* $Id$ */
|
||||
|
||||
/** @file newgrf_spritegroup.cpp */
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "openttd.h"
|
||||
#include "variables.h"
|
||||
|
@ -1,5 +1,7 @@
|
||||
/* $Id$ */
|
||||
|
||||
/** @file newgrf_spritegroup.h */
|
||||
|
||||
#ifndef NEWGRF_SPRITEGROUP_H
|
||||
#define NEWGRF_SPRITEGROUP_H
|
||||
|
||||
@ -11,12 +13,12 @@ struct SpriteGroup;
|
||||
/* 'Real' sprite groups contain a list of other result or callback sprite
|
||||
* groups. */
|
||||
struct RealSpriteGroup {
|
||||
// Loaded = in motion, loading = not moving
|
||||
// Each group contains several spritesets, for various loading stages
|
||||
/* Loaded = in motion, loading = not moving
|
||||
* Each group contains several spritesets, for various loading stages */
|
||||
|
||||
// XXX: For stations the meaning is different - loaded is for stations
|
||||
// with small amount of cargo whilst loading is for stations with a lot
|
||||
// of da stuff.
|
||||
/* XXX: For stations the meaning is different - loaded is for stations
|
||||
* with small amount of cargo whilst loading is for stations with a lot
|
||||
* of da stuff. */
|
||||
|
||||
byte num_loaded; ///< Number of loaded groups
|
||||
byte num_loading; ///< Number of loading groups
|
||||
@ -27,7 +29,7 @@ struct RealSpriteGroup {
|
||||
/* Shared by deterministic and random groups. */
|
||||
enum VarSpriteGroupScope {
|
||||
VSG_SCOPE_SELF,
|
||||
// Engine of consists for vehicles, city for stations.
|
||||
/* Engine of consists for vehicles, city for stations. */
|
||||
VSG_SCOPE_PARENT,
|
||||
};
|
||||
|
||||
@ -44,20 +46,20 @@ enum DeterministicSpriteGroupAdjustType {
|
||||
};
|
||||
|
||||
enum DeterministicSpriteGroupAdjustOperation {
|
||||
DSGA_OP_ADD, // a + b
|
||||
DSGA_OP_SUB, // a - b
|
||||
DSGA_OP_SMIN, // (signed) min(a, b)
|
||||
DSGA_OP_SMAX, // (signed) max(a, b)
|
||||
DSGA_OP_UMIN, // (unsigned) min(a, b)
|
||||
DSGA_OP_UMAX, // (unsigned) max(a, b)
|
||||
DSGA_OP_SDIV, // (signed) a / b
|
||||
DSGA_OP_SMOD, // (signed) a % b
|
||||
DSGA_OP_UDIV, // (unsigned) a / b
|
||||
DSGA_OP_UMOD, // (unsigned) a & b
|
||||
DSGA_OP_MUL, // a * b
|
||||
DSGA_OP_AND, // a & b
|
||||
DSGA_OP_OR, // a | b
|
||||
DSGA_OP_XOR, // a ^ b
|
||||
DSGA_OP_ADD, ///< a + b
|
||||
DSGA_OP_SUB, ///< a - b
|
||||
DSGA_OP_SMIN, ///< (signed) min(a, b)
|
||||
DSGA_OP_SMAX, ///< (signed) max(a, b)
|
||||
DSGA_OP_UMIN, ///< (unsigned) min(a, b)
|
||||
DSGA_OP_UMAX, ///< (unsigned) max(a, b)
|
||||
DSGA_OP_SDIV, ///< (signed) a / b
|
||||
DSGA_OP_SMOD, ///< (signed) a % b
|
||||
DSGA_OP_UDIV, ///< (unsigned) a / b
|
||||
DSGA_OP_UMOD, ///< (unsigned) a & b
|
||||
DSGA_OP_MUL, ///< a * b
|
||||
DSGA_OP_AND, ///< a & b
|
||||
DSGA_OP_OR, ///< a | b
|
||||
DSGA_OP_XOR, ///< a ^ b
|
||||
};
|
||||
|
||||
|
||||
@ -89,7 +91,7 @@ struct DeterministicSpriteGroup {
|
||||
DeterministicSpriteGroupAdjust *adjusts;
|
||||
DeterministicSpriteGroupRange *ranges; // Dynamically allocated
|
||||
|
||||
// Dynamically allocated, this is the sole owner
|
||||
/* Dynamically allocated, this is the sole owner */
|
||||
const SpriteGroup *default_group;
|
||||
};
|
||||
|
||||
@ -99,19 +101,15 @@ enum RandomizedSpriteGroupCompareMode {
|
||||
};
|
||||
|
||||
struct RandomizedSpriteGroup {
|
||||
// Take this object:
|
||||
VarSpriteGroupScope var_scope;
|
||||
VarSpriteGroupScope var_scope; ///< Take this object:
|
||||
|
||||
// Check for these triggers:
|
||||
RandomizedSpriteGroupCompareMode cmp_mode;
|
||||
RandomizedSpriteGroupCompareMode cmp_mode; ///< Check for these triggers:
|
||||
byte triggers;
|
||||
|
||||
// Look for this in the per-object randomized bitmask:
|
||||
byte lowest_randbit;
|
||||
byte num_groups; // must be power of 2
|
||||
byte lowest_randbit; ///< Look for this in the per-object randomized bitmask:
|
||||
byte num_groups; ///< must be power of 2
|
||||
|
||||
// Take the group with appropriate index:
|
||||
const SpriteGroup **groups;
|
||||
const SpriteGroup **groups; ///< Take the group with appropriate index:
|
||||
};
|
||||
|
||||
|
||||
@ -130,7 +128,7 @@ struct ResultSpriteGroup {
|
||||
};
|
||||
|
||||
struct TileLayoutSpriteGroup {
|
||||
byte num_sprites; /* Number of sprites in the spriteset, used for loading stages */
|
||||
byte num_sprites; ///< Number of sprites in the spriteset, used for loading stages
|
||||
struct DrawTileSprites *dts;
|
||||
};
|
||||
|
||||
|
@ -43,7 +43,7 @@ void ResetStationClasses()
|
||||
station_classes[i].spec = NULL;
|
||||
}
|
||||
|
||||
// Set up initial data
|
||||
/* Set up initial data */
|
||||
station_classes[0].id = 'DFLT';
|
||||
station_classes[0].name = STR_STAT_CLASS_DFLT;
|
||||
station_classes[0].stations = 1;
|
||||
@ -66,10 +66,10 @@ StationClassID AllocateStationClass(uint32 cls)
|
||||
{
|
||||
for (StationClassID i = STAT_CLASS_BEGIN; i < STAT_CLASS_MAX; i++) {
|
||||
if (station_classes[i].id == cls) {
|
||||
// ClassID is already allocated, so reuse it.
|
||||
/* ClassID is already allocated, so reuse it. */
|
||||
return i;
|
||||
} else if (station_classes[i].id == 0) {
|
||||
// This class is empty, so allocate it to the ClassID.
|
||||
/* This class is empty, so allocate it to the ClassID. */
|
||||
station_classes[i].id = cls;
|
||||
return i;
|
||||
}
|
||||
@ -168,8 +168,8 @@ const StationSpec *GetCustomStationSpec(StationClassID sclass, uint station)
|
||||
if (station < station_classes[sclass].stations)
|
||||
return station_classes[sclass].spec[station];
|
||||
|
||||
// If the custom station isn't defined any more, then the GRF file
|
||||
// probably was not loaded.
|
||||
/* If the custom station isn't defined any more, then the GRF file
|
||||
* probably was not loaded. */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -355,11 +355,11 @@ static uint32 StationGetVariable(const ResolverObject *object, byte variable, by
|
||||
case 0x41:
|
||||
case 0x46:
|
||||
case 0x47:
|
||||
case 0x49: return 0x2110000; /* Platforms, tracks & position */
|
||||
case 0x42: return 0; /* Rail type (XXX Get current type from GUI?) */
|
||||
case 0x43: return _current_player; /* Station owner */
|
||||
case 0x44: return 2; /* PBS status */
|
||||
case 0xFA: return max(_date - DAYS_TILL_ORIGINAL_BASE_YEAR, 0); /* Build date */
|
||||
case 0x49: return 0x2110000; // Platforms, tracks & position
|
||||
case 0x42: return 0; // Rail type (XXX Get current type from GUI?)
|
||||
case 0x43: return _current_player; // Station owner
|
||||
case 0x44: return 2; // PBS status
|
||||
case 0xFA: return max(_date - DAYS_TILL_ORIGINAL_BASE_YEAR, 0); // Build date
|
||||
}
|
||||
|
||||
*available = false;
|
||||
@ -370,16 +370,16 @@ static uint32 StationGetVariable(const ResolverObject *object, byte variable, by
|
||||
/* Calculated station variables */
|
||||
case 0x40: return GetPlatformInfoHelper(tile, false, false, false);
|
||||
case 0x41: return GetPlatformInfoHelper(tile, true, false, false);
|
||||
case 0x42: /* Terrain and rail type */
|
||||
case 0x42: // Terrain and rail type
|
||||
return ((_opt.landscape == LT_HILLY && GetTileZ(tile) > GetSnowLine()) ? 4 : 0) |
|
||||
(_opt.landscape == LT_DESERT ? GetTropicZone(tile) : 0) |
|
||||
(GetRailType(tile) << 8);
|
||||
case 0x43: return st->owner; /* Station owner */
|
||||
case 0x44: return 2; /* PBS status */
|
||||
case 0x43: return st->owner; // Station owner
|
||||
case 0x44: return 2; // PBS status
|
||||
case 0x45: return GetRailContinuationInfo(tile);
|
||||
case 0x46: return GetPlatformInfoHelper(tile, false, false, true);
|
||||
case 0x47: return GetPlatformInfoHelper(tile, true, false, true);
|
||||
case 0x48: { /* Accepted cargo types */
|
||||
case 0x48: { // Accepted cargo types
|
||||
CargoID cargo_type;
|
||||
uint32 value = 0;
|
||||
|
||||
@ -557,7 +557,7 @@ SpriteID GetCustomStationGroundRelocation(const StationSpec *statspec, const Sta
|
||||
ResolverObject object;
|
||||
|
||||
NewStationResolver(&object, statspec, st, tile);
|
||||
object.callback_param1 = 1; /* Indicate we are resolving the ground sprite */
|
||||
object.callback_param1 = 1; // Indicate we are resolving the ground sprite
|
||||
|
||||
group = ResolveStation(&object);
|
||||
if (group == NULL || group->type != SGT_RESULT) return 0;
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* $Id$ */
|
||||
|
||||
/** @file
|
||||
/** @file newgrf_text.cpp
|
||||
* Implementation of Action 04 "universal holder" structure and functions.
|
||||
* This file implements a linked-lists of strings,
|
||||
* holding everything that the newgrf action 04 will send over to OpenTTD.
|
||||
@ -122,7 +122,7 @@ const iso_grf iso_codes[] = {
|
||||
{"sv_SE", GRFLX_SWEDISH},
|
||||
{"tr_TR", GRFLX_TURKISH},
|
||||
{"uk_UA", GRFLX_UKRAINIAN},
|
||||
{"gen", GRFLB_GENERIC} //this is not iso code, but there has to be something...
|
||||
{"gen", GRFLB_GENERIC} ///< this is not iso code, but there has to be something...
|
||||
};
|
||||
|
||||
|
||||
@ -180,12 +180,12 @@ struct GRFTextEntry {
|
||||
|
||||
static uint _num_grf_texts = 0;
|
||||
static GRFTextEntry _grf_text[(1 << TABSIZE) * 3];
|
||||
static byte _currentLangID = GRFLX_ENGLISH; //by default, english is used.
|
||||
static byte _currentLangID = GRFLX_ENGLISH; ///< by default, english is used.
|
||||
|
||||
|
||||
char *TranslateTTDPatchCodes(const char *str)
|
||||
{
|
||||
char *tmp = MallocT<char>(strlen(str) * 10 + 1); /* Allocate space to allow for expansion */
|
||||
char *tmp = MallocT<char>(strlen(str) * 10 + 1); // Allocate space to allow for expansion
|
||||
char *d = tmp;
|
||||
bool unicode = false;
|
||||
WChar c;
|
||||
@ -198,7 +198,7 @@ char *TranslateTTDPatchCodes(const char *str)
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
const char *tmp = str; /* Used for UTF-8 decoding */
|
||||
const char *tmp = str; // Used for UTF-8 decoding
|
||||
|
||||
c = (byte)*str++;
|
||||
if (c == 0) break;
|
||||
|
@ -2,7 +2,7 @@
|
||||
#ifndef NEWGRF_TEXT_H
|
||||
#define NEWGRF_TEXT_H
|
||||
|
||||
/** @file
|
||||
/** @file newgrf_text.h
|
||||
* Header of Action 04 "universal holder" structure and functions
|
||||
*/
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
/* $Id$ */
|
||||
|
||||
/** @file news.h */
|
||||
|
||||
#ifndef NEWS_H
|
||||
#define NEWS_H
|
||||
|
||||
|
@ -64,14 +64,14 @@ StringID GetNewsStringNewVehicleAvail(const NewsItem *ni);
|
||||
StringID GetNewsStringBankrupcy(const NewsItem *ni);
|
||||
|
||||
static DrawNewsCallbackProc * const _draw_news_callback[] = {
|
||||
DrawNewsNewVehicleAvail, /* DNC_VEHICLEAVAIL */
|
||||
DrawNewsBankrupcy, /* DNC_BANKRUPCY */
|
||||
DrawNewsNewVehicleAvail, //< DNC_VEHICLEAVAIL
|
||||
DrawNewsBankrupcy, //< DNC_BANKRUPCY
|
||||
};
|
||||
|
||||
extern GetNewsStringCallbackProc * const _get_news_string_callback[];
|
||||
GetNewsStringCallbackProc * const _get_news_string_callback[] = {
|
||||
GetNewsStringNewVehicleAvail, /* DNC_VEHICLEAVAIL */
|
||||
GetNewsStringBankrupcy, /* DNC_BANKRUPCY */
|
||||
GetNewsStringNewVehicleAvail, ///< DNC_VEHICLEAVAIL
|
||||
GetNewsStringBankrupcy, ///< DNC_BANKRUPCY
|
||||
};
|
||||
|
||||
void InitNewsItemStructs()
|
||||
@ -104,7 +104,7 @@ void DrawNewsBorder(const Window *w)
|
||||
static void NewsWindowProc(Window *w, WindowEvent *e)
|
||||
{
|
||||
switch (e->event) {
|
||||
case WE_CREATE: { /* If chatbar is open at creation time, we need to go above it */
|
||||
case WE_CREATE: { // If chatbar is open at creation time, we need to go above it
|
||||
const Window *w1 = FindWindowById(WC_SEND_NETWORK_MSG, 0);
|
||||
w->message.msg = (w1 != NULL) ? w1->height : 0;
|
||||
} break;
|
||||
@ -189,20 +189,20 @@ static void NewsWindowProc(Window *w, WindowEvent *e)
|
||||
|
||||
case WE_KEYPRESS:
|
||||
if (e->we.keypress.keycode == WKC_SPACE) {
|
||||
// Don't continue.
|
||||
/* Don't continue. */
|
||||
e->we.keypress.cont = false;
|
||||
DeleteWindow(w);
|
||||
}
|
||||
break;
|
||||
|
||||
case WE_MESSAGE: /* The chatbar has notified us that is was either created or closed */
|
||||
case WE_MESSAGE: // The chatbar has notified us that is was either created or closed
|
||||
switch (e->we.message.msg) {
|
||||
case WE_CREATE: w->message.msg = e->we.message.wparam; break;
|
||||
case WE_DESTROY: w->message.msg = 0; break;
|
||||
}
|
||||
break;
|
||||
|
||||
case WE_TICK: { /* Scroll up newsmessages from the bottom in steps of 4 pixels */
|
||||
case WE_TICK: { // Scroll up newsmessages from the bottom in steps of 4 pixels
|
||||
int diff;
|
||||
int y = max(w->top - 4, _screen.height - w->height - 12 - w->message.msg);
|
||||
if (y == w->top) return;
|
||||
@ -260,7 +260,7 @@ void AddNewsItem(StringID string, uint32 flags, uint data_a, uint data_b)
|
||||
|
||||
if (_game_mode == GM_MENU) return;
|
||||
|
||||
// check the rare case that the oldest (to be overwritten) news item is open
|
||||
/* check the rare case that the oldest (to be overwritten) news item is open */
|
||||
if (_total_news == MAX_NEWS && (_oldest_news == _current_news || _oldest_news == _forced_news))
|
||||
MoveToNextItem();
|
||||
|
||||
@ -281,7 +281,8 @@ void AddNewsItem(StringID string, uint32 flags, uint data_a, uint data_b)
|
||||
/*DEBUG(misc, 0, "+cur %3d, old %2d, lat %3d, for %3d, tot %2d",
|
||||
_current_news, _oldest_news, _latest_news, _forced_news, _total_news);*/
|
||||
|
||||
{ /* Add news to _latest_news */
|
||||
/* Add news to _latest_news */
|
||||
{
|
||||
Window *w;
|
||||
NewsItem *ni = &_news_items[_latest_news];
|
||||
memset(ni, 0, sizeof(*ni));
|
||||
@ -290,7 +291,7 @@ void AddNewsItem(StringID string, uint32 flags, uint data_a, uint data_b)
|
||||
ni->display_mode = (byte)flags;
|
||||
ni->flags = (byte)(flags >> 8);
|
||||
|
||||
// show this news message in color?
|
||||
/* show this news message in color? */
|
||||
if (_cur_year >= _patches.colored_news_year) ni->flags |= NF_INCOLOR;
|
||||
|
||||
ni->type = (byte)(flags >> 16);
|
||||
@ -405,7 +406,7 @@ static inline void SetNewsDisplayValue(byte item, byte val)
|
||||
SB(_news_display_opt, item * 2, 2, val);
|
||||
}
|
||||
|
||||
// open up an own newspaper window for the news item
|
||||
/* open up an own newspaper window for the news item */
|
||||
static void ShowNewspaper(NewsItem *ni)
|
||||
{
|
||||
Window *w;
|
||||
@ -455,7 +456,7 @@ static void ShowNewspaper(NewsItem *ni)
|
||||
w->flags4 |= WF_DISABLE_VP_SCROLL;
|
||||
}
|
||||
|
||||
// show news item in the ticker
|
||||
/* show news item in the ticker */
|
||||
static void ShowTicker(const NewsItem *ni)
|
||||
{
|
||||
Window *w;
|
||||
@ -468,8 +469,8 @@ static void ShowTicker(const NewsItem *ni)
|
||||
}
|
||||
|
||||
|
||||
// Are we ready to show another news item?
|
||||
// Only if nothing is in the newsticker and no newspaper is displayed
|
||||
/** Are we ready to show another news item?
|
||||
* Only if nothing is in the newsticker and no newspaper is displayed */
|
||||
static bool ReadyForNextItem()
|
||||
{
|
||||
const Window *w;
|
||||
@ -479,15 +480,15 @@ static bool ReadyForNextItem()
|
||||
if (item >= MAX_NEWS) return true;
|
||||
ni = &_news_items[item];
|
||||
|
||||
// Ticker message
|
||||
// Check if the status bar message is still being displayed?
|
||||
/* Ticker message
|
||||
* Check if the status bar message is still being displayed? */
|
||||
w = FindWindowById(WC_STATUS_BAR, 0);
|
||||
if (w != NULL && WP(w, const def_d).data_1 > -1280) return false;
|
||||
|
||||
// Newspaper message, decrement duration counter
|
||||
/* Newspaper message, decrement duration counter */
|
||||
if (ni->duration != 0) ni->duration--;
|
||||
|
||||
// neither newsticker nor newspaper are running
|
||||
/* neither newsticker nor newspaper are running */
|
||||
return (ni->duration == 0 || FindWindowById(WC_NEWS_WINDOW, 0) == NULL);
|
||||
}
|
||||
|
||||
@ -496,18 +497,18 @@ static void MoveToNextItem()
|
||||
DeleteWindowById(WC_NEWS_WINDOW, 0);
|
||||
_forced_news = INVALID_NEWS;
|
||||
|
||||
// if we're not at the last item, then move on
|
||||
/* if we're not at the last item, then move on */
|
||||
if (_current_news != _latest_news) {
|
||||
NewsItem *ni;
|
||||
|
||||
_current_news = (_current_news == INVALID_NEWS) ? _oldest_news : increaseIndex(_current_news);
|
||||
ni = &_news_items[_current_news];
|
||||
|
||||
// check the date, don't show too old items
|
||||
/* check the date, don't show too old items */
|
||||
if (_date - _news_items_age[ni->type] > ni->date) return;
|
||||
|
||||
switch (GetNewsDisplayValue(ni->type)) {
|
||||
case 0: { /* Off - show nothing only a small reminder in the status bar */
|
||||
case 0: { // Off - show nothing only a small reminder in the status bar
|
||||
Window *w = FindWindowById(WC_STATUS_BAR, 0);
|
||||
|
||||
if (w != NULL) {
|
||||
@ -517,14 +518,14 @@ static void MoveToNextItem()
|
||||
break;
|
||||
}
|
||||
|
||||
case 1: /* Summary - show ticker, but if forced big, cascade to full */
|
||||
case 1: // Summary - show ticker, but if forced big, cascade to full
|
||||
if (!(ni->flags & NF_FORCE_BIG)) {
|
||||
ShowTicker(ni);
|
||||
break;
|
||||
}
|
||||
/* Fallthrough */
|
||||
|
||||
case 2: /* Full - show newspaper*/
|
||||
case 2: // Full - show newspaper
|
||||
ShowNewspaper(ni);
|
||||
break;
|
||||
}
|
||||
@ -533,7 +534,7 @@ static void MoveToNextItem()
|
||||
|
||||
void NewsLoop()
|
||||
{
|
||||
// no news item yet
|
||||
/* no news item yet */
|
||||
if (_total_news == 0) return;
|
||||
|
||||
if (ReadyForNextItem()) MoveToNextItem();
|
||||
@ -544,10 +545,10 @@ static void ShowNewsMessage(NewsID i)
|
||||
{
|
||||
if (_total_news == 0) return;
|
||||
|
||||
// Delete the news window
|
||||
/* Delete the news window */
|
||||
DeleteWindowById(WC_NEWS_WINDOW, 0);
|
||||
|
||||
// setup forced news item
|
||||
/* setup forced news item */
|
||||
_forced_news = i;
|
||||
|
||||
if (_forced_news != INVALID_NEWS) {
|
||||
@ -649,7 +650,7 @@ static void MessageHistoryWndProc(Window *w, WindowEvent *e)
|
||||
show = min(_total_news, w->vscroll.cap);
|
||||
|
||||
for (p = w->vscroll.pos; p < w->vscroll.pos + show; p++) {
|
||||
// get news in correct order
|
||||
/* get news in correct order */
|
||||
const NewsItem *ni = &_news_items[getNews(p)];
|
||||
|
||||
SetDParam(0, ni->date);
|
||||
|
34
src/npf.cpp
34
src/npf.cpp
@ -1,5 +1,7 @@
|
||||
/* $Id$ */
|
||||
|
||||
/** @file npf.cpp */
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "openttd.h"
|
||||
#include "bridge_map.h"
|
||||
@ -99,14 +101,14 @@ static TileIndex CalcClosestStationTile(StationID station, TileIndex tile)
|
||||
uint x;
|
||||
uint y;
|
||||
|
||||
// we are going the aim for the x coordinate of the closest corner
|
||||
// but if we are between those coordinates, we will aim for our own x coordinate
|
||||
/* we are going the aim for the x coordinate of the closest corner
|
||||
* but if we are between those coordinates, we will aim for our own x coordinate */
|
||||
x = clamp(TileX(tile), minx, maxx);
|
||||
|
||||
// same for y coordinate, see above comment
|
||||
/* same for y coordinate, see above comment */
|
||||
y = clamp(TileY(tile), miny, maxy);
|
||||
|
||||
// return the tile of our target coordinates
|
||||
/* return the tile of our target coordinates */
|
||||
return TileXY(x, y);
|
||||
}
|
||||
|
||||
@ -121,7 +123,7 @@ static int32 NPFCalcStationOrTileHeuristic(AyStar* as, AyStarNode* current, Open
|
||||
TileIndex to = fstd->dest_coords;
|
||||
uint dist;
|
||||
|
||||
// for train-stations, we are going to aim for the closest station tile
|
||||
/* for train-stations, we are going to aim for the closest station tile */
|
||||
if (as->user_data[NPF_TYPE] == TRANSPORT_RAIL && fstd->station_index != INVALID_STATION)
|
||||
to = CalcClosestStationTile(fstd->station_index, from);
|
||||
|
||||
@ -173,7 +175,7 @@ static uint NPFTunnelCost(AyStarNode* current)
|
||||
FindLengthOfTunnelResult flotr;
|
||||
flotr = FindLengthOfTunnel(tile, ReverseDiagDir(exitdir));
|
||||
return flotr.length * NPF_TILE_LENGTH;
|
||||
//TODO: Penalty for tunnels?
|
||||
/* @todo: Penalty for tunnels? */
|
||||
} else {
|
||||
/* We are entering the tunnel, the enter tile is just a
|
||||
* straight track */
|
||||
@ -244,19 +246,19 @@ static void NPFMarkTile(TileIndex tile)
|
||||
|
||||
static int32 NPFWaterPathCost(AyStar* as, AyStarNode* current, OpenListNode* parent)
|
||||
{
|
||||
//TileIndex tile = current->tile;
|
||||
/* TileIndex tile = current->tile; */
|
||||
int32 cost = 0;
|
||||
Trackdir trackdir = (Trackdir)current->direction;
|
||||
|
||||
cost = _trackdir_length[trackdir]; /* Should be different for diagonal tracks */
|
||||
cost = _trackdir_length[trackdir]; // Should be different for diagonal tracks
|
||||
|
||||
if (IsBuoyTile(current->tile) && IsDiagonalTrackdir(trackdir))
|
||||
cost += _patches.npf_buoy_penalty; /* A small penalty for going over buoys */
|
||||
cost += _patches.npf_buoy_penalty; // A small penalty for going over buoys
|
||||
|
||||
if (current->direction != NextTrackdir((Trackdir)parent->path.node.direction))
|
||||
cost += _patches.npf_water_curve_penalty;
|
||||
|
||||
/* TODO More penalties? */
|
||||
/* @todo More penalties? */
|
||||
|
||||
return cost;
|
||||
}
|
||||
@ -385,8 +387,8 @@ static int32 NPFRailPathCost(AyStar* as, AyStarNode* current, OpenListNode* pare
|
||||
/* Check for turns */
|
||||
if (current->direction != NextTrackdir((Trackdir)parent->path.node.direction))
|
||||
cost += _patches.npf_rail_curve_penalty;
|
||||
//TODO, with realistic acceleration, also the amount of straight track between
|
||||
// curves should be taken into account, as this affects the speed limit.
|
||||
/*TODO, with realistic acceleration, also the amount of straight track between
|
||||
* curves should be taken into account, as this affects the speed limit. */
|
||||
|
||||
/* Check for reverse in depot */
|
||||
if (IsTileDepotType(tile, TRANSPORT_RAIL) && as->EndNodeCheck(as, &new_node) != AYSTAR_FOUND_END_NODE) {
|
||||
@ -484,7 +486,7 @@ static bool VehicleMayEnterTile(Owner owner, TileIndex tile, DiagDirection enter
|
||||
break;
|
||||
}
|
||||
|
||||
return true; /* no need to check */
|
||||
return true; // no need to check
|
||||
}
|
||||
|
||||
|
||||
@ -544,7 +546,7 @@ static void NPFFollowTrack(AyStar* aystar, OpenListNode* current)
|
||||
/* Find out the exit direction first */
|
||||
if (IsRoadStopTile(src_tile)) {
|
||||
exitdir = GetRoadStopDir(src_tile);
|
||||
} else { /* Train or road depot */
|
||||
} else { // Train or road depot
|
||||
exitdir = GetDepotDirection(src_tile, type);
|
||||
}
|
||||
|
||||
@ -610,7 +612,7 @@ static void NPFFollowTrack(AyStar* aystar, OpenListNode* current)
|
||||
DiagDirection exitdir;
|
||||
if (IsRoadStopTile(dst_tile)) {
|
||||
exitdir = GetRoadStopDir(dst_tile);
|
||||
} else { /* Road or train depot */
|
||||
} else { // Road or train depot
|
||||
exitdir = GetDepotDirection(dst_tile, type);
|
||||
}
|
||||
/* Find the trackdirs that are available for a depot or station with this
|
||||
@ -640,7 +642,7 @@ static void NPFFollowTrack(AyStar* aystar, OpenListNode* current)
|
||||
/* Check for oneway signal against us */
|
||||
if (IsTileType(dst_tile, MP_RAILWAY) && GetRailTileType(dst_tile) == RAIL_TILE_SIGNALS) {
|
||||
if (HasSignalOnTrackdir(dst_tile, ReverseTrackdir(dst_trackdir)) && !HasSignalOnTrackdir(dst_tile, dst_trackdir))
|
||||
// if one way signal not pointing towards us, stop going in this direction.
|
||||
/* if one way signal not pointing towards us, stop going in this direction. */
|
||||
break;
|
||||
}
|
||||
{
|
||||
|
47
src/npf.h
47
src/npf.h
@ -1,5 +1,7 @@
|
||||
/* $Id$ */
|
||||
|
||||
/** @file npf.h */
|
||||
|
||||
#ifndef NPF_H
|
||||
#define NPF_H
|
||||
|
||||
@ -9,9 +11,9 @@
|
||||
#include "vehicle.h"
|
||||
#include "tile.h"
|
||||
|
||||
//mowing grass
|
||||
/* mowing grass */
|
||||
enum {
|
||||
NPF_HASH_BITS = 12, /* The size of the hash used in pathfinding. Just changing this value should be sufficient to change the hash size. Should be an even value. */
|
||||
NPF_HASH_BITS = 12, ///< The size of the hash used in pathfinding. Just changing this value should be sufficient to change the hash size. Should be an even value.
|
||||
/* Do no change below values */
|
||||
NPF_HASH_SIZE = 1 << NPF_HASH_BITS,
|
||||
NPF_HASH_HALFBITS = NPF_HASH_BITS / 2,
|
||||
@ -35,33 +37,38 @@ enum {
|
||||
NPF_INFINITE_PENALTY = 1000 * NPF_TILE_LENGTH
|
||||
};
|
||||
|
||||
struct NPFFindStationOrTileData { /* Meant to be stored in AyStar.targetdata */
|
||||
TileIndex dest_coords; /* An indication of where the station is, for heuristic purposes, or the target tile */
|
||||
StationID station_index; /* station index we're heading for, or INVALID_STATION when we're heading for a tile */
|
||||
/* Meant to be stored in AyStar.targetdata */
|
||||
struct NPFFindStationOrTileData {
|
||||
TileIndex dest_coords; ///< An indication of where the station is, for heuristic purposes, or the target tile
|
||||
StationID station_index; ///< station index we're heading for, or INVALID_STATION when we're heading for a tile
|
||||
};
|
||||
|
||||
enum { /* Indices into AyStar.userdata[] */
|
||||
NPF_TYPE = 0, /* Contains a TransportTypes value */
|
||||
NPF_OWNER, /* Contains an Owner value */
|
||||
NPF_RAILTYPES, /* Contains a bitmask the compatible RailTypes of the engine when NPF_TYPE == TRANSPORT_RAIL. Unused otherwise. */
|
||||
/* Indices into AyStar.userdata[] */
|
||||
enum {
|
||||
NPF_TYPE = 0, ///< Contains a TransportTypes value
|
||||
NPF_OWNER, ///< Contains an Owner value
|
||||
NPF_RAILTYPES, ///< Contains a bitmask the compatible RailTypes of the engine when NPF_TYPE == TRANSPORT_RAIL. Unused otherwise.
|
||||
};
|
||||
|
||||
enum { /* Indices into AyStarNode.userdata[] */
|
||||
NPF_TRACKDIR_CHOICE = 0, /* The trackdir chosen to get here */
|
||||
/* Indices into AyStarNode.userdata[] */
|
||||
enum {
|
||||
NPF_TRACKDIR_CHOICE = 0, ///< The trackdir chosen to get here
|
||||
NPF_NODE_FLAGS,
|
||||
};
|
||||
|
||||
enum NPFNodeFlag { /* Flags for AyStarNode.userdata[NPF_NODE_FLAGS]. Use NPFGetBit() and NPFGetBit() to use them. */
|
||||
NPF_FLAG_SEEN_SIGNAL, /* Used to mark that a signal was seen on the way, for rail only */
|
||||
NPF_FLAG_REVERSE, /* Used to mark that this node was reached from the second start node, if applicable */
|
||||
NPF_FLAG_LAST_SIGNAL_RED, /* Used to mark that the last signal on this path was red */
|
||||
/* Flags for AyStarNode.userdata[NPF_NODE_FLAGS]. Use NPFGetBit() and NPFGetBit() to use them. */
|
||||
enum NPFNodeFlag {
|
||||
NPF_FLAG_SEEN_SIGNAL, ///< Used to mark that a signal was seen on the way, for rail only
|
||||
NPF_FLAG_REVERSE, ///< Used to mark that this node was reached from the second start node, if applicable
|
||||
NPF_FLAG_LAST_SIGNAL_RED, ///< Used to mark that the last signal on this path was red
|
||||
};
|
||||
|
||||
struct NPFFoundTargetData { /* Meant to be stored in AyStar.userpath */
|
||||
uint best_bird_dist; /* The best heuristic found. Is 0 if the target was found */
|
||||
uint best_path_dist; /* The shortest path. Is (uint)-1 if no path is found */
|
||||
Trackdir best_trackdir; /* The trackdir that leads to the shortest path/closest birds dist */
|
||||
AyStarNode node; /* The node within the target the search led us to */
|
||||
/* Meant to be stored in AyStar.userpath */
|
||||
struct NPFFoundTargetData {
|
||||
uint best_bird_dist; ///< The best heuristic found. Is 0 if the target was found
|
||||
uint best_path_dist; ///< The shortest path. Is (uint)-1 if no path is found
|
||||
Trackdir best_trackdir; ///< The trackdir that leads to the shortest path/closest birds dist
|
||||
AyStarNode node; ///< The node within the target the search led us to
|
||||
};
|
||||
|
||||
/* These functions below are _not_ re-entrant, in favor of speed! */
|
||||
|
Loading…
Reference in New Issue
Block a user