tTString documentation corrected; A_TSTRING ability added to prevent new tstring-enabled servers from confusing old clients - vaccinewars - be a doctor and try to vaccinate the world
git clone git://src.adamsgaard.dk/vaccinewars
Log
Files
Refs
README
LICENSE
---
commit 3c83bb986b888873e2206ff5785e0d14d9f9c309
parent c3b35b148c21d646f8af7b12d2f0379c3154576e
Author: Ben Webb 
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 forms" are; you must
 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,
-Names.Bitch = "bitch^no^bitcho^ac^bitche"
+the original word, separating them by _ (underline) symbols. For example,
+Names.Bitch = "bitch_no_bitcho_ac_bitche"
specifies two alternative forms for "bitch", identified by the "no" and "ac" codes. You can then use "bitcho" anywhere that "bitch" is normally used by translating the relevant string as "%tno" (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;iAbil.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;iID);
    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
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__ */