tTString documentation corrected; A_TSTRING ability added to prevent new tstrin… | |
git clone git://src.adamsgaard.dk/vaccinewars | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 3c83bb986b888873e2206ff5785e0d14d9f9c309 | |
parent c3b35b148c21d646f8af7b12d2f0379c3154576e | |
Author: Ben Webb <[email protected]> | |
Date: Tue, 19 Dec 2000 13:32:19 +0000 | |
TString documentation corrected; A_TSTRING ability added to prevent new | |
ttstring-enabled servers from confusing old clients | |
Diffstat: | |
M doc/i18n.html | 4 ++-- | |
M src/dopewars.h | 10 ++++++---- | |
M src/message.c | 42 +++++++++++++++++++++++++----… | |
M src/tstring.c | 8 ++++++++ | |
M src/tstring.h | 2 ++ | |
5 files changed, 52 insertions(+), 14 deletions(-) | |
--- | |
diff --git a/doc/i18n.html b/doc/i18n.html | |
t@@ -113,8 +113,8 @@ Obviously dopewars cannot guess what your "alternative for… | |
specify them yourself. Essentially, when setting a string in a dopewars | |
configuration file (or the defaults, which are set in dopewars.c) alternative | |
forms can be added by alternating two-letter codes and alternative forms after | |
-the original word, separating them by ^ symbols. For example,<br> | |
-<tt>Names.Bitch = "bitch^no^bitcho^ac^bitche"</tt><br> | |
+the original word, separating them by _ (underline) symbols. For example,<br> | |
+<tt>Names.Bitch = "bitch_no_bitcho_ac_bitche"</tt><br> | |
specifies two alternative forms for "bitch", identified by the "<tt>no</tt>" | |
and "<tt>ac</tt>" codes. You can then use "bitcho" anywhere that "bitch" is | |
normally used by translating the relevant string as "<tt>%tno</tt>" (and to | |
diff --git a/src/dopewars.h b/src/dopewars.h | |
t@@ -70,10 +70,12 @@ typedef long price_t; | |
typedef long long price_t; | |
#endif | |
-#define A_PLAYERID 0 | |
-#define A_DRUGVALUE 1 | |
-#define A_NEWFIGHT 2 | |
-#define A_NUM 3 | |
+#define A_PLAYERID 0 /* Use numeric IDs rather than player names | |
+ in network messages */ | |
+#define A_DRUGVALUE 1 /* Server keeps track of purchase price of drugs … | |
+#define A_NEWFIGHT 2 /* Use new unified fighting code */ | |
+#define A_TSTRING 3 /* We understand the %Txx (tstring) notation */ | |
+#define A_NUM 4 | |
typedef struct ABILITIES { | |
gboolean Local[A_NUM]; | |
gboolean Remote[A_NUM]; | |
diff --git a/src/message.c b/src/message.c | |
t@@ -218,6 +218,7 @@ void InitAbilities(Player *Play) { | |
Play->Abil.Local[A_PLAYERID]=TRUE; | |
Play->Abil.Local[A_NEWFIGHT]=TRUE; | |
Play->Abil.Local[A_DRUGVALUE]=(DrugValue ? TRUE : FALSE); | |
+ Play->Abil.Local[A_TSTRING]=TRUE; | |
if (!Network) for (i=0;i<A_NUM;i++) { | |
Play->Abil.Remote[i]=Play->Abil.Shared[i]=Play->Abil.Local[i]; | |
t@@ -506,14 +507,28 @@ void SendSpyReport(Player *To,Player *SpiedOn) { | |
g_string_free(text,TRUE); | |
} | |
+#define NUMNAMES 8 | |
+ | |
void SendInitialData(Player *To) { | |
+ gchar *LocalNames[NUMNAMES] = { Names.Bitch,Names.Bitches,Names.Gun, | |
+ Names.Guns,Names.Drug,Names.Drugs, | |
+ Names.Month,Names.Year }; | |
+ gint i; | |
GString *text; | |
+ | |
if (!Network) return; | |
+ if (!HaveAbility(To,A_TSTRING)) for (i=0;i<NUMNAMES;i++) { | |
+ LocalNames[i] = GetDefaultTString(LocalNames[i]); | |
+ } | |
text=g_string_new(""); | |
- g_string_sprintf(text,"%s^%d^%d^%d^%s^%s^%s^%s^%s^%s^%s^%s^", | |
- VERSION,NumLocation,NumGun,NumDrug, | |
- Names.Bitch,Names.Bitches,Names.Gun,Names.Guns, | |
- Names.Drug,Names.Drugs,Names.Month,Names.Year); | |
+ g_string_sprintf(text,"%s^%d^%d^%d^",VERSION,NumLocation,NumGun,NumDrug); | |
+ for (i=0;i<NUMNAMES;i++) { | |
+ g_string_append(text,LocalNames[i]); | |
+ g_string_append_c(text,'^'); | |
+ } | |
+ if (!HaveAbility(To,A_TSTRING)) for (i=0;i<NUMNAMES;i++) { | |
+ g_free(LocalNames[i]); | |
+ } | |
if (HaveAbility(To,A_PLAYERID)) g_string_sprintfa(text,"%d^",To->ID); | |
SendServerMessage(NULL,C_NONE,C_INIT,To,text->str); | |
g_string_free(text,TRUE); | |
t@@ -548,30 +563,41 @@ void ReceiveInitialData(Player *Play,char *Data) { | |
} | |
void SendMiscData(Player *To) { | |
- gchar *text,*prstr[2]; | |
+ gchar *text,*prstr[2],*LocalName; | |
int i; | |
+ gboolean HaveTString; | |
if (!Network) return; | |
+ HaveTString=HaveAbility(To,A_TSTRING); | |
text=g_strdup_printf("0^%c%s^%s^",DT_PRICES, | |
(prstr[0]=pricetostr(Prices.Spy)), | |
(prstr[1]=pricetostr(Prices.Tipoff))); | |
SendServerMessage(NULL,C_NONE,C_DATA,To,text); | |
g_free(prstr[0]); g_free(prstr[1]); g_free(text); | |
for (i=0;i<NumGun;i++) { | |
- text=g_strdup_printf("%d^%c%s^%s^%d^%d^",i,DT_GUN,Gun[i].Name, | |
+ if (HaveTString) LocalName=Gun[i].Name; | |
+ else LocalName=GetDefaultTString(Gun[i].Name); | |
+ text=g_strdup_printf("%d^%c%s^%s^%d^%d^",i,DT_GUN,LocalName, | |
(prstr[0]=pricetostr(Gun[i].Price)), | |
Gun[i].Space,Gun[i].Damage); | |
+ if (!HaveTString) g_free(LocalName); | |
SendServerMessage(NULL,C_NONE,C_DATA,To,text); | |
g_free(prstr[0]); g_free(text); | |
} | |
for (i=0;i<NumDrug;i++) { | |
- text=g_strdup_printf("%d^%c%s^%s^%s^",i,DT_DRUG,Drug[i].Name, | |
+ if (HaveTString) LocalName=Drug[i].Name; | |
+ else LocalName=GetDefaultTString(Drug[i].Name); | |
+ text=g_strdup_printf("%d^%c%s^%s^%s^",i,DT_DRUG,LocalName, | |
(prstr[0]=pricetostr(Drug[i].MinPrice)), | |
(prstr[1]=pricetostr(Drug[i].MaxPrice))); | |
+ if (!HaveTString) g_free(LocalName); | |
SendServerMessage(NULL,C_NONE,C_DATA,To,text); | |
g_free(prstr[0]); g_free(prstr[1]); g_free(text); | |
} | |
for (i=0;i<NumLocation;i++) { | |
- text=g_strdup_printf("%d^%c%s^",i,DT_LOCATION,Location[i].Name); | |
+ if (HaveTString) LocalName=Location[i].Name; | |
+ else LocalName=GetDefaultTString(Location[i].Name); | |
+ text=g_strdup_printf("%d^%c%s^",i,DT_LOCATION,LocalName); | |
+ if (!HaveTString) g_free(LocalName); | |
SendServerMessage(NULL,C_NONE,C_DATA,To,text); | |
g_free(text); | |
} | |
diff --git a/src/tstring.c b/src/tstring.c | |
t@@ -42,6 +42,14 @@ typedef struct _FmtData { | |
char Type; | |
} FmtData; | |
+gchar *GetDefaultTString(gchar *tstring) { | |
+ gchar *dstr,*pt; | |
+ dstr=g_strdup(tstring); | |
+ pt=strchr(dstr,'_'); | |
+ if (pt) *pt='\0'; | |
+ return dstr; | |
+} | |
+ | |
gchar *GetTranslatedString(gchar *str,gchar *code,gboolean Caps) { | |
gchar *dstr,*pt,*tstr,*Default,*tcode; | |
diff --git a/src/tstring.h b/src/tstring.h | |
t@@ -35,4 +35,6 @@ gchar *dpg_strdup_printf(gchar *format, ...); | |
void dpg_string_sprintf(GString *string, gchar *format, ...); | |
void dpg_string_sprintfa(GString *string, gchar *format, ...); | |
+gchar *GetDefaultTString(gchar *tstring); | |
+ | |
#endif /* __TSTRING_H__ */ |