summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorludde <ludde@openttd.org>2005-07-16 20:58:04 +0000
committerludde <ludde@openttd.org>2005-07-16 20:58:04 +0000
commit594dd34e84e78b03e1cdeb7cf262707fd714a5fa (patch)
tree69f0f649731f03bc4b9a79121d4b839e7400a826
parentcb5fc8f6ffa0062f395bbf742390db6411f4fe32 (diff)
downloadopenttd-594dd34e84e78b03e1cdeb7cf262707fd714a5fa.tar.xz
(svn r2594) Fix: [strgen] Misc updates to the string system.
- Renamed the plural command to "P" instead of "PLURAL". Now write something like this to append an s on plural: {P "" s}. (You can optionally still add an argument index to explicitly specifiy which number that's used) - Removed the pluralized cargo strings from the string files. The new method is to use the plural specifier {P} - Added support for genders. First add "##gender der das die" on top, then use {G=der} on a cargoname/industry to set the gender, and to switch between genders do something like {G neu neu neue} {STRING} - Updated the swedish/english translation with P strings.
-rw-r--r--aircraft_gui.c6
-rw-r--r--engine_gui.c6
-rw-r--r--industry_gui.c8
-rw-r--r--lang/english.txt85
-rw-r--r--lang/swedish.txt50
-rw-r--r--misc.c4
-rw-r--r--roadveh_gui.c4
-rw-r--r--ship_gui.c6
-rw-r--r--station_gui.c4
-rw-r--r--strgen/strgen.c88
-rw-r--r--strings.c35
-rw-r--r--train_gui.c8
-rw-r--r--variables.h3
13 files changed, 159 insertions, 148 deletions
diff --git a/aircraft_gui.c b/aircraft_gui.c
index a235e68d9..33bbef5ed 100644
--- a/aircraft_gui.c
+++ b/aircraft_gui.c
@@ -245,7 +245,7 @@ static void AircraftRefitWndProc(Window *w, WindowEvent *e)
int32 cost = DoCommandByTile(v->tile, v->index, WP(w,refit_d).cargo, DC_QUERY_COST, CMD_REFIT_AIRCRAFT);
if (!CmdFailed(cost)) {
SetDParam(2, cost);
- SetDParam(0, _cargoc.names_long_p[WP(w,refit_d).cargo]);
+ SetDParam(0, _cargoc.names_long[WP(w,refit_d).cargo]);
SetDParam(1, _aircraft_refit_capacity);
DrawString(1, 137, STR_A041_NEW_CAPACITY_COST_OF_REFIT, 0);
}
@@ -377,10 +377,10 @@ static void AircraftDetailsWndProc(Window *w, WindowEvent *e)
DrawString(60, y, STR_A011_BUILT_VALUE, 0);
y += 10;
- SetDParam(0, _cargoc.names_long_p[v->cargo_type]);
+ SetDParam(0, _cargoc.names_long[v->cargo_type]);
SetDParam(1, v->cargo_cap);
u = v->next;
- SetDParam(2, _cargoc.names_long_p[u->cargo_type]);
+ SetDParam(2, _cargoc.names_long[u->cargo_type]);
SetDParam(3, u->cargo_cap);
DrawString(60, y, STR_A019_CAPACITY + (u->cargo_cap == 0), 0);
y += 14;
diff --git a/engine_gui.c b/engine_gui.c
index f5817e4f0..72e939b5b 100644
--- a/engine_gui.c
+++ b/engine_gui.c
@@ -135,7 +135,7 @@ static void DrawTrainEngineInfo(int engine, int x, int y, int maxw)
SetDParam(5, STR_8838_N_A);
if (cap != 0) {
SetDParam(6, cap << multihead);
- SetDParam(5, _cargoc.names_long_p[rvi->cargo_type]);
+ SetDParam(5, _cargoc.names_long[rvi->cargo_type]);
}
DrawStringMultiCenter(x, y, STR_885B_COST_WEIGHT_T_SPEED_POWER, maxw);
}
@@ -217,7 +217,7 @@ static void DrawRoadVehEngineInfo(int engine, int x, int y, int maxw)
SetDParam(2, rvi->running_cost * _price.roadveh_running >> 8);
SetDParam(4, rvi->capacity);
- SetDParam(3, _cargoc.names_long_p[rvi->cargo_type]);
+ SetDParam(3, _cargoc.names_long[rvi->cargo_type]);
DrawStringMultiCenter(x, y, STR_902A_COST_SPEED_RUNNING_COST, maxw);
}
@@ -253,7 +253,7 @@ static void DrawShipEngineInfo(int engine, int x, int y, int maxw)
const ShipVehicleInfo *svi = ShipVehInfo(engine);
SetDParam(0, svi->base_cost * (_price.ship_base >> 3) >> 5);
SetDParam(1, svi->max_speed * 10 >> 5);
- SetDParam(2, _cargoc.names_long_p[svi->cargo_type]);
+ SetDParam(2, _cargoc.names_long[svi->cargo_type]);
SetDParam(3, svi->capacity);
SetDParam(4, svi->running_cost * _price.ship_running >> 8);
DrawStringMultiCenter(x, y, STR_982E_COST_MAX_SPEED_CAPACITY, maxw);
diff --git a/industry_gui.c b/industry_gui.c
index 6c98343fc..7a8743807 100644
--- a/industry_gui.c
+++ b/industry_gui.c
@@ -301,8 +301,8 @@ static void IndustryViewWndProc(Window *w, WindowEvent *e)
if (i->produced_cargo[0] != CT_INVALID) {
DrawString(2, 117, STR_482A_PRODUCTION_LAST_MONTH, 0);
+ SetDParam(0, _cargoc.names_long[i->produced_cargo[0]]);
SetDParam(1, i->total_production[0]);
- SetDParam(0, _cargoc.names_long_s[i->produced_cargo[0]] + ((i->total_production[0]!=1)<<5));
SetDParam(2, i->pct_transported[0] * 100 >> 8);
DrawString(4 + (NEED_ALTERB ? 30 : 0), 127, STR_482B_TRANSPORTED, 0);
@@ -311,8 +311,8 @@ static void IndustryViewWndProc(Window *w, WindowEvent *e)
DrawArrowButtons(5, 127, (WP(w,vp2_d).data_2 == 1 ? WP(w,vp2_d).data_3 : 0));
if (i->produced_cargo[1] != CT_INVALID) {
+ SetDParam(0, _cargoc.names_long[i->produced_cargo[1]]);
SetDParam(1, i->total_production[1]);
- SetDParam(0, _cargoc.names_long_s[i->produced_cargo[1]] + ((i->total_production[1]!=1)<<5));
SetDParam(2, i->pct_transported[1] * 100 >> 8);
DrawString(4 + (NEED_ALTERB ? 30 : 0), 137, STR_482B_TRANSPORTED, 0);
// Let's put out those buttons..
@@ -586,12 +586,12 @@ static void IndustryDirectoryWndProc(Window *w, WindowEvent *e)
i = GetIndustry(_industry_sort[p]);
SetDParam(0, i->index);
if (i->produced_cargo[0] != 0xFF) {
+ SetDParam(1, _cargoc.names_long[i->produced_cargo[0]]);
SetDParam(2, i->total_production[0]);
- SetDParam(1, _cargoc.names_long_s[i->produced_cargo[0]] + ((i->total_production[0]!=1)<<5));
if (i->produced_cargo[1] != 0xFF) {
+ SetDParam(3, _cargoc.names_long[i->produced_cargo[1]]);
SetDParam(4, i->total_production[1]);
- SetDParam(3, _cargoc.names_long_s[i->produced_cargo[1]] + ((i->total_production[1]!=1)<<5));
SetDParam(5, i->pct_transported[0] * 100 >> 8);
SetDParam(6, i->pct_transported[1] * 100 >> 8);
DrawString(4, 28+n*10, STR_INDUSTRYDIR_ITEM_TWO, 0);
diff --git a/lang/english.txt b/lang/english.txt
index 4d7b03bf3..61124ae22 100644
--- a/lang/english.txt
+++ b/lang/english.txt
@@ -1,6 +1,7 @@
##name English
##ownname English (UK)
##isocode en_GB
+##plural 0
##id 0x0000
STR_NULL :
@@ -82,69 +83,37 @@ STR_004B_BATTERY :Battery
STR_004C_PLASTIC :Plastic
STR_004D_FIZZY_DRINK :Fizzy Drink
STR_004E :
-STR_004F_PASSENGER :{COMMA} passenger
-STR_0050_TON_OF_COAL :{COMMA} tonne of coal
-STR_0051_BAG_OF_MAIL :{COMMA} bag of mail
+STR_004F_PASSENGER :{COMMA} passenger{P "" s}
+STR_0050_TON_OF_COAL :{COMMA} tonne{P "" s} of coal
+STR_0051_BAG_OF_MAIL :{COMMA} bag{P "" s} of mail
STR_0052_OF_OIL :{VOLUME} of oil
-STR_0053_ITEM_OF_LIVESTOCK :{COMMA} item of livestock
-STR_0054_CRATE_OF_GOODS :{COMMA} crate of goods
-STR_0055_TON_OF_GRAIN :{COMMA} tonne of grain
-STR_0056_TON_OF_WOOD :{COMMA} tonne of wood
-STR_0057_TON_OF_IRON_ORE :{COMMA} tonne of iron ore
-STR_0058_TON_OF_STEEL :{COMMA} tonne of steel
-STR_0059_BAG_OF_VALUABLES :{COMMA} bag of valuables
-STR_005A_TON_OF_COPPER_ORE :{COMMA} tonne of copper ore
-STR_005B_TON_OF_MAIZE :{COMMA} tonne of maize
-STR_005C_TON_OF_FRUIT :{COMMA} tonne of fruit
-STR_005D_BAG_OF_DIAMONDS :{COMMA} bag of diamonds
-STR_005E_TON_OF_FOOD :{COMMA} tonne of food
-STR_005F_TON_OF_PAPER :{COMMA} tonne of paper
-STR_0060_BAG_OF_GOLD :{COMMA} bag of gold
+STR_0053_ITEM_OF_LIVESTOCK :{COMMA} item{P "" s} of livestock
+STR_0054_CRATE_OF_GOODS :{COMMA} crate{P "" s} of goods
+STR_0055_TON_OF_GRAIN :{COMMA} tonne{P "" s} of grain
+STR_0056_TON_OF_WOOD :{COMMA} tonne{P "" s} of wood
+STR_0057_TON_OF_IRON_ORE :{COMMA} tonne{P "" s} of iron ore
+STR_0058_TON_OF_STEEL :{COMMA} tonne{P "" s} of steel
+STR_0059_BAG_OF_VALUABLES :{COMMA} bag{P "" s} of valuables
+STR_005A_TON_OF_COPPER_ORE :{COMMA} tonne{P "" s} of copper ore
+STR_005B_TON_OF_MAIZE :{COMMA} tonne{P "" s} of maize
+STR_005C_TON_OF_FRUIT :{COMMA} tonne{P "" s} of fruit
+STR_005D_BAG_OF_DIAMONDS :{COMMA} bag{P "" s} of diamonds
+STR_005E_TON_OF_FOOD :{COMMA} tonne{P "" s} of food
+STR_005F_TON_OF_PAPER :{COMMA} tonne{P "" s} of paper
+STR_0060_BAG_OF_GOLD :{COMMA} bag{P "" s} of gold
STR_0061_OF_WATER :{VOLUME} of water
-STR_0062_TON_OF_WHEAT :{COMMA} tonne of wheat
+STR_0062_TON_OF_WHEAT :{COMMA} tonne{P "" s} of wheat
STR_0063_OF_RUBBER :{VOLUME} of rubber
-STR_0064_TON_OF_SUGAR :{COMMA} tonne of sugar
-STR_0065_TOY :{COMMA} toy
-STR_0066_BAG_OF_CANDY :{COMMA} bag of sweets
+STR_0064_TON_OF_SUGAR :{COMMA} tonne{P "" s} of sugar
+STR_0065_TOY :{COMMA} toy{P "" s}
+STR_0066_BAG_OF_CANDY :{COMMA} bag{P "" s} of sweets
STR_0067_OF_COLA :{VOLUME} of cola
-STR_0068_TON_OF_COTTON_CANDY :{COMMA} tonne of candyfloss
-STR_0069_BUBBLE :{COMMA} bubble
-STR_006A_TON_OF_TOFFEE :{COMMA} tonne of toffee
-STR_006B_BATTERY :{COMMA} battery
+STR_0068_TON_OF_COTTON_CANDY :{COMMA} tonne{P "" s} of candyfloss
+STR_0069_BUBBLE :{COMMA} bubble{P "" s}
+STR_006A_TON_OF_TOFFEE :{COMMA} tonne{P "" s} of toffee
+STR_006B_BATTERY :{COMMA} batter{P y ies}
STR_006C_OF_PLASTIC :{VOLUME} of plastic
-STR_006D_FIZZY_DRINK :{COMMA} fizzy drink
-STR_006E :
-STR_006F_PASSENGERS :{COMMA} passengers
-STR_0070_TONS_OF_COAL :{COMMA} tonnes of coal
-STR_0071_BAGS_OF_MAIL :{COMMA} bags of mail
-STR_0072_OF_OIL :{VOLUME} of oil
-STR_0073_ITEMS_OF_LIVESTOCK :{COMMA} items of livestock
-STR_0074_CRATES_OF_GOODS :{COMMA} crates of goods
-STR_0075_TONS_OF_GRAIN :{COMMA} tonnes of grain
-STR_0076_TONS_OF_WOOD :{COMMA} tonnes of wood
-STR_0077_TONS_OF_IRON_ORE :{COMMA} tonnes of iron ore
-STR_0078_TONS_OF_STEEL :{COMMA} tonnes of steel
-STR_0079_BAGS_OF_VALUABLES :{COMMA} bags of valuables
-STR_007A_TONS_OF_COPPER_ORE :{COMMA} tonnes of copper ore
-STR_007B_TONS_OF_MAIZE :{COMMA} tonnes of maize
-STR_007C_TONS_OF_FRUIT :{COMMA} tonnes of fruit
-STR_007D_BAGS_OF_DIAMONDS :{COMMA} bags of diamonds
-STR_007E_TONS_OF_FOOD :{COMMA} tonnes of food
-STR_007F_TONS_OF_PAPER :{COMMA} tonnes of paper
-STR_0080_BAGS_OF_GOLD :{COMMA} bags of gold
-STR_0081_OF_WATER :{VOLUME} of water
-STR_0082_TONS_OF_WHEAT :{COMMA} tonnes of wheat
-STR_0083_OF_RUBBER :{VOLUME} of rubber
-STR_0084_TONS_OF_SUGAR :{COMMA} tonnes of sugar
-STR_0085_TOYS :{COMMA} toys
-STR_0086_BAGS_OF_CANDY :{COMMA} bags of sweets
-STR_0087_OF_COLA :{VOLUME} of cola
-STR_0088_TONS_OF_COTTON_CANDY :{COMMA} tonnes of candyfloss
-STR_0089_BUBBLES :{COMMA} bubbles
-STR_008A_TONS_OF_TOFFEE :{COMMA} tonnes of toffee
-STR_008B_BATTERIES :{COMMA} batteries
-STR_008C_OF_PLASTIC :{VOLUME} of plastic
-STR_008D_FIZZY_DRINKS :{COMMA} fizzy drinks
+STR_006D_FIZZY_DRINK :{COMMA} fizzy drink{P "" s}
STR_008E :
STR_008F_PS :{TINYFONT}PS
STR_0090_CL :{TINYFONT}CL
diff --git a/lang/swedish.txt b/lang/swedish.txt
index 523419f7c..6fb875d38 100644
--- a/lang/swedish.txt
+++ b/lang/swedish.txt
@@ -84,67 +84,35 @@ STR_004D_FIZZY_DRINK :läsk
STR_004E :
STR_004F_PASSENGER :{COMMA} passagerare
STR_0050_TON_OF_COAL :{COMMA} ton kol
-STR_0051_BAG_OF_MAIL :{COMMA} postsäck
+STR_0051_BAG_OF_MAIL :{COMMA} postsäck{P "" ar}
STR_0052_OF_OIL :{VOLUME} olja
STR_0053_ITEM_OF_LIVESTOCK :{COMMA} boskap
-STR_0054_CRATE_OF_GOODS :{COMMA} låda gods
+STR_0054_CRATE_OF_GOODS :{COMMA} låd{P a or} gods
STR_0055_TON_OF_GRAIN :{COMMA} ton spannmål
STR_0056_TON_OF_WOOD :{COMMA} ton timmer
STR_0057_TON_OF_IRON_ORE :{COMMA} ton järnmalm
STR_0058_TON_OF_STEEL :{COMMA} ton stål
-STR_0059_BAG_OF_VALUABLES :{COMMA} värdesäck
+STR_0059_BAG_OF_VALUABLES :{COMMA} värdesäck{P "" ar}
STR_005A_TON_OF_COPPER_ORE :{COMMA} ton kopparmalm
STR_005B_TON_OF_MAIZE :{COMMA} ton majs
STR_005C_TON_OF_FRUIT :{COMMA} ton frukt
-STR_005D_BAG_OF_DIAMONDS :{COMMA} diamantsäck
+STR_005D_BAG_OF_DIAMONDS :{COMMA} diamantsäck{P "" ar}
STR_005E_TON_OF_FOOD :{COMMA} ton mat
STR_005F_TON_OF_PAPER :{COMMA} ton papper
-STR_0060_BAG_OF_GOLD :{COMMA} guldsäck
+STR_0060_BAG_OF_GOLD :{COMMA} guldsäck{P "" ar}
STR_0061_OF_WATER :{VOLUME} vatten
STR_0062_TON_OF_WHEAT :{COMMA} ton vete
STR_0063_OF_RUBBER :{VOLUME} gummi
STR_0064_TON_OF_SUGAR :{COMMA} ton socker
-STR_0065_TOY :{COMMA} leksak
-STR_0066_BAG_OF_CANDY :{COMMA} godispåse
+STR_0065_TOY :{COMMA} leksak{P "" er}
+STR_0066_BAG_OF_CANDY :{COMMA} godispås{P e ar}
STR_0067_OF_COLA :{VOLUME} kola
STR_0068_TON_OF_COTTON_CANDY :{COMMA} ton spunnet socker
-STR_0069_BUBBLE :{COMMA} bubbla
+STR_0069_BUBBLE :{COMMA} bubbl{P a or}
STR_006A_TON_OF_TOFFEE :{COMMA} ton knäck
-STR_006B_BATTERY :{COMMA} batteri
+STR_006B_BATTERY :{COMMA} batteri{P "" er}
STR_006C_OF_PLASTIC :{VOLUME} plast
STR_006D_FIZZY_DRINK :{COMMA} läsk
-STR_006E :
-STR_006F_PASSENGERS :{COMMA} passagerare
-STR_0070_TONS_OF_COAL :{COMMA} ton kol
-STR_0071_BAGS_OF_MAIL :{COMMA} postsäckar
-STR_0072_OF_OIL :{VOLUME} olja
-STR_0073_ITEMS_OF_LIVESTOCK :{COMMA} stycken boskap
-STR_0074_CRATES_OF_GOODS :{COMMA} lådor gods
-STR_0075_TONS_OF_GRAIN :{COMMA} ton spannmål
-STR_0076_TONS_OF_WOOD :{COMMA} ton timmer
-STR_0077_TONS_OF_IRON_ORE :{COMMA} ton järnmalm
-STR_0078_TONS_OF_STEEL :{COMMA} ton stål
-STR_0079_BAGS_OF_VALUABLES :{COMMA} värdesäckar
-STR_007A_TONS_OF_COPPER_ORE :{COMMA} ton kopparmalm
-STR_007B_TONS_OF_MAIZE :{COMMA} ton majs
-STR_007C_TONS_OF_FRUIT :{COMMA} ton frukt
-STR_007D_BAGS_OF_DIAMONDS :{COMMA} diamantsäckar
-STR_007E_TONS_OF_FOOD :{COMMA} ton mat
-STR_007F_TONS_OF_PAPER :{COMMA} ton papper
-STR_0080_BAGS_OF_GOLD :{COMMA} guldsäckar
-STR_0081_OF_WATER :{VOLUME} vatten
-STR_0082_TONS_OF_WHEAT :{COMMA} ton vete
-STR_0083_OF_RUBBER :{VOLUME} gummi
-STR_0084_TONS_OF_SUGAR :{COMMA} ton socker
-STR_0085_TOYS :{COMMA} leksaker
-STR_0086_BAGS_OF_CANDY :{COMMA} godispåsar
-STR_0087_OF_COLA :{VOLUME} kola
-STR_0088_TONS_OF_COTTON_CANDY :{COMMA} ton spunnet socker
-STR_0089_BUBBLES :{COMMA} bubblor
-STR_008A_TONS_OF_TOFFEE :{COMMA} ton knäck
-STR_008B_BATTERIES :{COMMA} batterier
-STR_008C_OF_PLASTIC :{VOLUME} plast
-STR_008D_FIZZY_DRINKS :{COMMA} läsk
STR_008E :
STR_008F_PS :{TINYFONT}PS
STR_0090_CL :{TINYFONT}KL
diff --git a/misc.c b/misc.c
index 193c7fa22..f7b6c120a 100644
--- a/misc.c
+++ b/misc.c
@@ -430,8 +430,8 @@ void InitializeLandscapeVariables(bool only_constants)
str = lpd->names[i];
_cargoc.names_s[i] = str;
_cargoc.names_p[i] = (str += 0x20);
- _cargoc.names_long_s[i] = (str += 0x20);
- _cargoc.names_long_p[i] = (str += 0x20);
+ _cargoc.names_long[i] = (str += 0x20);
+// _cargoc.names_long_p[i] = (str += 0x20);
_cargoc.names_short[i] = (str += 0x20);
_cargoc.weights[i] = lpd->weights[i];
diff --git a/roadveh_gui.c b/roadveh_gui.c
index e715cd9f3..972770885 100644
--- a/roadveh_gui.c
+++ b/roadveh_gui.c
@@ -39,7 +39,7 @@ void DrawRoadVehPurchaseInfo(int x, int y, EngineID engine_number)
y += 10;
/* Cargo type + capacity */
- SetDParam(0, _cargoc.names_long_p[rvi->cargo_type]);
+ SetDParam(0, _cargoc.names_long[rvi->cargo_type]);
SetDParam(1, rvi->capacity);
SetDParam(2, STR_EMPTY);
DrawString(x, y, STR_PURCHASE_INFO_CAPACITY, 0);
@@ -138,7 +138,7 @@ static void RoadVehDetailsWndProc(Window *w, WindowEvent *e)
SetDParam(2, v->value);
DrawString(34, 57, STR_9011_BUILT_VALUE, 0);
- SetDParam(0, _cargoc.names_long_p[v->cargo_type]);
+ SetDParam(0, _cargoc.names_long[v->cargo_type]);
SetDParam(1, v->cargo_cap);
DrawString(34, 67, STR_9012_CAPACITY, 0);
diff --git a/ship_gui.c b/ship_gui.c
index f27bf458c..12943d85d 100644
--- a/ship_gui.c
+++ b/ship_gui.c
@@ -32,7 +32,7 @@ void DrawShipPurchaseInfo(int x, int y, EngineID engine_number)
y += 10;
/* Cargo type + capacity */
- SetDParam(0, _cargoc.names_long_p[svi->cargo_type]);
+ SetDParam(0, _cargoc.names_long[svi->cargo_type]);
SetDParam(1, svi->capacity);
SetDParam(2, svi->refittable ? STR_9842_REFITTABLE : STR_EMPTY);
DrawString(x,y, STR_PURCHASE_INFO_CAPACITY, 0);
@@ -87,7 +87,7 @@ static void ShipRefitWndProc(Window *w, WindowEvent *e)
int32 cost = DoCommandByTile(v->tile, v->index, WP(w,refit_d).cargo, DC_QUERY_COST, CMD_REFIT_SHIP);
if (!CmdFailed(cost)) {
SetDParam(2, cost);
- SetDParam(0, _cargoc.names_long_p[WP(w,refit_d).cargo]);
+ SetDParam(0, _cargoc.names_long[WP(w,refit_d).cargo]);
SetDParam(1, v->cargo_cap);
DrawString(1, 137, STR_9840_NEW_CAPACITY_COST_OF_REFIT, 0);
}
@@ -214,7 +214,7 @@ static void ShipDetailsWndProc(Window *w, WindowEvent *e)
SetDParam(2, v->value);
DrawString(74, 57, STR_9816_BUILT_VALUE, 0);
- SetDParam(0, _cargoc.names_long_p[v->cargo_type]);
+ SetDParam(0, _cargoc.names_long[v->cargo_type]);
SetDParam(1, v->cargo_cap);
DrawString(74, 67, STR_9817_CAPACITY, 0);
diff --git a/station_gui.c b/station_gui.c
index 50c4c7e3e..df4d2b66e 100644
--- a/station_gui.c
+++ b/station_gui.c
@@ -372,7 +372,7 @@ static void DrawStationViewWindow(Window *w)
if ( st->goods[i].enroute_from == station_id) {
if (--pos < 0) {
SetDParam(1, waiting);
- SetDParam(0, _cargoc.names_long_s[i] + (waiting==1 ? 0 : 32));
+ SetDParam(0, _cargoc.names_long[i]);
DrawStringRightAligned(x + 234, y, STR_0009, 0);
y += 10;
}
@@ -380,7 +380,7 @@ static void DrawStationViewWindow(Window *w)
/* enroute */
if (--pos < 0) {
SetDParam(1, waiting);
- SetDParam(0, _cargoc.names_long_s[i] + (waiting==1 ? 0 : 32));
+ SetDParam(0, _cargoc.names_long[i]);
DrawStringRightAligned(x + 234, y, STR_000A_EN_ROUTE_FROM, 0);
y += 10;
}
diff --git a/strgen/strgen.c b/strgen/strgen.c
index 5cac8147c..5b3e95e5b 100644
--- a/strgen/strgen.c
+++ b/strgen/strgen.c
@@ -59,6 +59,9 @@ static uint32 _hash;
static char _lang_name[32], _lang_ownname[32], _lang_isocode[16];
static byte _lang_pluralform;
+static char _genders[8][8];
+static int _numgenders;
+
// for each plural value, this is the number of plural forms.
static const byte _plural_form_counts[] = { 2,1,2,3,3,3,3,3,4 };
@@ -245,16 +248,28 @@ char *ParseWord(char **buf)
// Forward declaration
static int TranslateArgumentIdx(int arg, bool relative);
+static void EmitWordList(char **words, int nw)
+{
+ int i,j;
+
+ PutByte(nw);
+ for(i=0; i<nw; i++)
+ PutByte(strlen(words[i]));
+ for(i=0; i<nw; i++) {
+ for(j=0; words[i][j]; j++)
+ PutByte(words[i][j]);
+ }
+}
+
static void EmitPlural(char *buf, int value)
{
- int v,i,j;
+ int v;
bool relative;
char *words[5];
int nw = 0;
- // Parse out the number.
- if (!ParseRelNum(&buf, &v, &relative))
- Fatal("Plural param invalid");
+ // Parse out the number, if one exists.
+ if (!ParseRelNum(&buf, &v, &relative)) { v = -1; relative = true; }
// Parse each string
for(nw=0; nw<5; nw++) {
@@ -272,16 +287,48 @@ static void EmitPlural(char *buf, int value)
PutByte(0x7D);
PutByte(TranslateArgumentIdx(v, relative));
- PutByte(nw);
- for(i=0; i<nw; i++)
- PutByte(strlen(words[i]));
- for(i=0; i<nw; i++) {
- for(j=0; words[i][j]; j++)
- PutByte(words[i][j]);
- }
+ EmitWordList(words, nw);
}
+static void EmitGender(char *buf, int value)
+{
+ int v;
+ bool relative;
+ char *words[8];
+ int nw;
+
+ if (buf[0] == '=') {
+ buf++;
+
+ // This is a {G=DER} command
+ for(nw=0; ;nw++) {
+ if (nw >= 8)
+ Fatal("G argument '%s' invalid", buf);
+ if (!strcmp(buf, _genders[nw]))
+ break;
+ }
+ // now nw contains the gender index
+ PutByte(0x87);
+ PutByte(nw);
+
+ } else {
+ // This is a {G 0 foo bar two} command.
+ if (!ParseRelNum(&buf, &v, &relative)) { v = 0; relative = true; }
+
+ for(nw=0; nw<8; nw++) {
+ words[nw] = ParseWord(&buf);
+ if (!words[nw])
+ break;
+ }
+ if (nw != _numgenders) Fatal("Bad # of arguments for gender command");
+ PutByte(0x85);
+ PutByte(13);
+ PutByte(TranslateArgumentIdx(v, relative));
+ EmitWordList(words, nw);
+ }
+}
+
static const CmdStruct _cmd_structs[] = {
// Update position
@@ -346,8 +393,10 @@ static const CmdStruct _cmd_structs[] = {
{"STATIONFEATURES", EmitEscapedByte, 10, 1}, // station features string, icons of the features
{"INDUSTRY", EmitEscapedByte, 11, 1}, // industry, takes an industry #
+ {"VOLUME", EmitEscapedByte, 12, 1},
- {"PLURAL", EmitPlural, 0, 0, true}, // plural specifier
+ {"P", EmitPlural, 0, 0, true}, // plural specifier
+ {"G", EmitGender, 0, 0, true}, // gender specifier
{"DATE_LONG", EmitSingleByte, 0x82, 1},
{"DATE_SHORT", EmitSingleByte, 0x83, 1},
@@ -355,7 +404,6 @@ static const CmdStruct _cmd_structs[] = {
{"VELOCITY", EmitSingleByte, 0x84, 1},
{"SKIP", EmitSingleByte, 0x86, 1},
- {"VOLUME", EmitSingleByte, 0x87, 1},
{"STRING", EmitSingleByte, 0x88, 1},
@@ -431,7 +479,7 @@ static const CmdStruct *ParseCommandString(char **str, char *param, int *argno,
start = s;
for(;;) {
c = *s++;
- if (c == '}' || c == ' ')
+ if (c == '}' || c == ' ' || c == '=')
break;
if (c == '\0') {
Error("Missing } from command '%s'", start);
@@ -445,7 +493,8 @@ static const CmdStruct *ParseCommandString(char **str, char *param, int *argno,
return NULL;
}
- if (c == ' ') {
+ if (c != '}') {
+ if (c == '=') s--;
// copy params
start = s;
for(;;) {
@@ -482,6 +531,15 @@ static void HandlePragma(char *str)
_lang_pluralform = atoi(str + 7);
if (_lang_pluralform >= lengthof(_plural_form_counts))
Fatal("Invalid pluralform %d", _lang_pluralform);
+ } else if (!memcmp(str, "gender ", 7)) {
+ char *buf = str + 7, *s;
+ int i;
+ for(i=0; i<8; i++) {
+ s = ParseWord(&buf);
+ if (!s) break;
+ ttd_strlcpy(_genders[i], s, sizeof(_genders[i]));
+ _numgenders++;
+ }
} else {
Fatal("unknown pragma '%s'", str);
}
diff --git a/strings.c b/strings.c
index 20293d667..7cec1534b 100644
--- a/strings.c
+++ b/strings.c
@@ -525,7 +525,7 @@ static char *FormatString(char *buff, const char *str, const int32 *argv)
case 0x7C: // Move argument pointer
argv = argv_orig + (byte)*str++;
break;
- case 0x7D: { // {PLURAL}
+ case 0x7D: { // {P}
int32 v = argv_orig[(byte)*str++]; // contains the number that determines plural
int len;
str = ParseStringChoice(str, DeterminePluralForm(v), buff, &len);
@@ -640,6 +640,24 @@ static char *FormatString(char *buff, const char *str, const int32 *argv)
break;
}
+ case 12: { // {VOLUME}
+ buff = FormatCommaNumber(buff, GetInt32(&argv) * 1000);
+ buff = strecpy(buff, " ", NULL);
+ buff = strecpy(buff, GetStringPtr(STR_LITERS), NULL);
+ break;
+ }
+
+ case 13: { // {G 0 Der Die Das}
+ byte *s = (byte*)GetStringPtr(argv_orig[(byte)*str++]); // contains the string that determines gender.
+ int len;
+ int gender = 0;
+ if (s && s[0] == 0x87)
+ gender = s[1];
+ str = ParseStringChoice(str, gender, buff, &len);
+ buff += len;
+ break;
+ }
+
default:
error("!invalid escape sequence in string");
}
@@ -648,10 +666,11 @@ static char *FormatString(char *buff, const char *str, const int32 *argv)
case 0x86: // {SKIP}
argv++;
break;
- case 0x87: // {VOLUME}
- buff = FormatCommaNumber(buff, GetInt32(&argv) * 1000);
- buff = strecpy(buff, " ", NULL);
- buff = strecpy(buff, GetStringPtr(STR_LITERS), NULL);
+
+ // This sets up the gender for the string.
+ // We just ignore this one. It's used somewhere else.
+ case 0x87: // {GENDER 0}
+ str++;
break;
case 0x88: {// {STRING}
@@ -667,10 +686,8 @@ static char *FormatString(char *buff, const char *str, const int32 *argv)
// Layout now is:
// 8bit - cargo type
// 16-bit - cargo count
- int cargo_str = _cargoc.names_long_s[GetInt32(&argv)];
- // Now check if the cargo count is 1, if it is, increase string by 32.
- if (GetInt32(&argv) != 1) cargo_str += 32;
- buff = GetStringWithArgs(buff, cargo_str, argv - 1);
+ StringID cargo_str = _cargoc.names_long[GetInt32(&argv)];
+ buff = GetStringWithArgs(buff, cargo_str, argv);
break;
}
diff --git a/train_gui.c b/train_gui.c
index ccd36e4a5..fb09cbbb3 100644
--- a/train_gui.c
+++ b/train_gui.c
@@ -60,7 +60,7 @@ void DrawTrainEnginePurchaseInfo(int x, int y, EngineID engine_number)
SetDParam(0, STR_8838_N_A);
SetDParam(2, STR_EMPTY);
if (rvi->capacity != 0) {
- SetDParam(0, _cargoc.names_long_p[rvi->cargo_type]);
+ SetDParam(0, _cargoc.names_long[rvi->cargo_type]);
SetDParam(1, rvi->capacity << multihead);
SetDParam(2, STR_9842_REFITTABLE);
}
@@ -101,7 +101,7 @@ void DrawTrainWagonPurchaseInfo(int x, int y, EngineID engine_number)
y += 10;
/* Cargo type + capacity */
- SetDParam(0, _cargoc.names_long_p[rvi->cargo_type]);
+ SetDParam(0, _cargoc.names_long[rvi->cargo_type]);
SetDParam(1, rvi->capacity);
SetDParam(2, refittable ? STR_9842_REFITTABLE : STR_EMPTY);
DrawString(x, y, STR_PURCHASE_INFO_CAPACITY, 0);
@@ -730,7 +730,7 @@ static void RailVehicleRefitWndProc(Window *w, WindowEvent *e)
int32 cost = DoCommandByTile(v->tile, v->index, WP(w,refit_d).cargo, DC_QUERY_COST, CMD_REFIT_RAIL_VEHICLE);
if (!CmdFailed(cost)) {
SetDParam(2, cost);
- SetDParam(0, _cargoc.names_long_p[WP(w,refit_d).cargo]);
+ SetDParam(0, _cargoc.names_long[WP(w,refit_d).cargo]);
SetDParam(1, _returned_refit_amount);
DrawString(1, 137, STR_9840_NEW_CAPACITY_COST_OF_REFIT, 0);
}
@@ -1010,8 +1010,8 @@ static void TrainDetailsInfoTab(const Vehicle *v, int x, int y)
static void TrainDetailsCapacityTab(const Vehicle *v, int x, int y)
{
if (v->cargo_cap != 0) {
+ SetDParam(0, _cargoc.names_long[v->cargo_type]);
SetDParam(1, v->cargo_cap);
- SetDParam(0, _cargoc.names_long_p[v->cargo_type]);
DrawString(x, y, STR_013F_CAPACITY, 0);
}
}
diff --git a/variables.h b/variables.h
index 94140d9be..55502c3e2 100644
--- a/variables.h
+++ b/variables.h
@@ -379,8 +379,7 @@ VARDEF FILE *_log_file_fd;
typedef struct {
StringID names_s[NUM_CARGO];
StringID names_p[NUM_CARGO];
- StringID names_long_s[NUM_CARGO];
- StringID names_long_p[NUM_CARGO];
+ StringID names_long[NUM_CARGO];
StringID names_short[NUM_CARGO];
byte weights[NUM_CARGO];
SpriteID sprites[NUM_CARGO];