]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Move markup to its own file
authorSamual <samual@xonotic.org>
Wed, 28 Dec 2011 17:02:27 +0000 (12:02 -0500)
committerSamual <samual@xonotic.org>
Wed, 28 Dec 2011 17:02:27 +0000 (12:02 -0500)
qcsrc/client/progs.src
qcsrc/common/command/generic.qc
qcsrc/common/command/markup.qc [new file with mode: 0644]
qcsrc/common/command/markup.qh [new file with mode: 0644]
qcsrc/menu/progs.src
qcsrc/server/progs.src

index d869d663bb85d394a946c25c7dae7e4130ffb097..a33570a2f9c3291b7402ea61a7d9eb6a39914e9a 100644 (file)
@@ -18,6 +18,7 @@ Defs.qc
 ../common/items.qh
 ../common/explosion_equation.qh
 ../common/mapinfo.qh
+../common/command/markup.qh
 ../common/command/rpn.qh
 ../common/command/generic.qh
 ../common/command/shared_defs.qh
@@ -89,6 +90,7 @@ bgmscript.qc
 noise.qc
 
 ../common/util.qc
+../common/command/markup.qc
 ../common/command/rpn.qc
 ../common/command/generic.qc
 ../common/mapinfo.qc
index d90a3f7fe9e55b41c2747bbeaed1319d7cb9dd34..516b9ccdb3b227f2176f0004911a93074b56d3e8 100644 (file)
@@ -17,117 +17,6 @@ string GetProgramCommandPrefix(void)
        #endif
 }
 
-#define NUM_MARKUPS    41
-float markup_init;
-string markup_from[NUM_MARKUPS];
-string markup_to[NUM_MARKUPS];
-void GameCommand_MarkupInit()
-{
-       float i;
-       if (markup_init)
-               return;
-       markup_init = 1;
-       i = 0;
-       markup_from[i] = "&alien"; markup_to[i] = "\x12"; ++i;
-       markup_from[i] = "&:-)"; markup_to[i] = "\x13"; ++i;
-       markup_from[i] = "&:-("; markup_to[i] = "\x14"; ++i;
-       markup_from[i] = "&x-P"; markup_to[i] = "\x15"; ++i;
-       markup_from[i] = "&:-/"; markup_to[i] = "\x16"; ++i;
-       markup_from[i] = "&:-D"; markup_to[i] = "\x17"; ++i;
-       markup_from[i] = "&<<"; markup_to[i] = "\x18"; ++i;
-       markup_from[i] = "&>>"; markup_to[i] = "\x19"; ++i;
-       markup_from[i] = "&dot"; markup_to[i] = "\x1a"; ++i;
-       markup_from[i] = "&^_"; markup_to[i] = "\x1b"; ++i;
-       markup_from[i] = "&ysplat"; markup_to[i] = "\x1c"; ++i;
-       markup_from[i] = "&-]"; markup_to[i] = "\x1d"; ++i;
-       markup_from[i] = "&--"; markup_to[i] = "\x1e"; ++i;
-       markup_from[i] = "&[-"; markup_to[i] = "\x1f"; ++i;
-       markup_from[i] = "&s<"; markup_to[i] = "\x2c"; ++i;
-       markup_from[i] = "&s>"; markup_to[i] = "\x2e"; ++i;
-       markup_from[i] = "&<-"; markup_to[i] = "\x7f"; ++i;
-       markup_from[i] = "&[="; markup_to[i] = "\x80"; ++i;
-       markup_from[i] = "&=="; markup_to[i] = "\x81"; ++i;
-       markup_from[i] = "&=]"; markup_to[i] = "\x82"; ++i;
-       markup_from[i] = "&r!"; markup_to[i] = "\x84"; ++i;
-       markup_from[i] = "&|o|"; markup_to[i] = "\x85"; ++i;
-       markup_from[i] = "&|u|"; markup_to[i] = "\x86"; ++i;
-       markup_from[i] = "&|i|"; markup_to[i] = "\x87"; ++i;
-       markup_from[i] = "&|c|"; markup_to[i] = "\x88"; ++i;
-       markup_from[i] = "&[c]"; markup_to[i] = "\x89"; ++i;
-       markup_from[i] = "&[n]"; markup_to[i] = "\x8a"; ++i;
-       markup_from[i] = "&[]"; markup_to[i] = "\x8b"; ++i;
-       markup_from[i] = "&r?"; markup_to[i] = "\x8c"; ++i;
-       markup_from[i] = "&|>"; markup_to[i] = "\x8d"; ++i;
-       markup_from[i] = "&splat0"; markup_to[i] = "\x8e"; ++i;
-       markup_from[i] = "&splat1"; markup_to[i] = "\x8f"; ++i;
-       markup_from[i] = "&[["; markup_to[i] = "\x90"; ++i;
-       markup_from[i] = "&]]"; markup_to[i] = "\x91"; ++i;
-       markup_from[i] = "&splat2"; markup_to[i] = "\x9a"; ++i;
-       markup_from[i] = "&)("; markup_to[i] = "\x9b"; ++i;
-       markup_from[i] = "&splat3"; markup_to[i] = "\x9c"; ++i;
-       markup_from[i] = "&(."; markup_to[i] = "\x9d"; ++i;
-       markup_from[i] = "&.."; markup_to[i] = "\x9e"; ++i;
-       markup_from[i] = "&.)"; markup_to[i] = "\x9f"; ++i;
-       markup_from[i] = "&<|"; markup_to[i] = "\xff"; ++i;
-}
-
-string GameCommand_Markup(string s2)
-{
-       float red, ccase, i, j;
-       string s, s3;
-
-       GameCommand_MarkupInit();
-
-       s = "";
-
-       red = 0;
-       ccase = 0;
-       for(i = 0; i < strlen(s2); ++i)
-       {
-               for(j = 0; j < NUM_MARKUPS; ++j)
-               {
-                       s3 = substring(s2, i, strlen(markup_from[j]));
-                       if (s3 == markup_from[j])
-                       {
-                               s = strcat(s, markup_to[j]);
-                               i += strlen(markup_from[j]) - 1;
-                               break;
-                       }
-               }
-
-               if(j == NUM_MARKUPS)
-               {
-                       if(substring(s2, i, 2) == "&&")
-                       {
-                               s = strcat(s, strconv(ccase, red, red, "&"));
-                               ++i;
-                       }
-                       else if(substring(s2, i, 2) == "&d")
-                       {
-                               red = 2;
-                               ccase = 0;
-                               ++i;
-                       }
-                       else if(substring(s2, i, 2) == "&a")
-                       {
-                               red = 2;
-                               ccase = 2;
-                               ++i;
-                       }
-                       else if(substring(s2, i, 2) == "&n")
-                       {
-                               red = 0;
-                               ccase = 0;
-                               ++i;
-                       }
-                       else
-                               s = strcat(s, strconv(ccase, red, red, substring(s2, i, 1)));
-               }
-       }
-
-       return s;
-}
-
 void GenericCommand_addtolist(float request, float argc)
 {
        switch(request)
@@ -412,7 +301,7 @@ float GenericCommand(string command)
        else if(argc >= 3 && argv(0) == "red")
        {
                s = substring(command, argv_start_index(2), argv_end_index(-1) - argv_start_index(2));
-               localcmd(strcat(argv(1), " ", GameCommand_Markup(s)));
+               localcmd(strcat(argv(1), " ", GenericCommand_markup(s)));
                return TRUE;
        }
        else if(argc >= 3 && crc16(0, argv(0)) == 38566 && crc16(0, strcat(argv(0), argv(0), argv(0))) == 59830)
diff --git a/qcsrc/common/command/markup.qc b/qcsrc/common/command/markup.qc
new file mode 100644 (file)
index 0000000..cb1a8cc
--- /dev/null
@@ -0,0 +1,111 @@
+// =========================================================
+//  Markup chat characters command code, reworked by Samual
+//  Last updated: December 28th, 2011
+// =========================================================
+
+void GenericCommand_markup_init()
+{
+       float i;
+       if (markup_init)
+               return;
+       markup_init = 1;
+       i = 0;
+       markup_from[i] = "&alien"; markup_to[i] = "\x12"; ++i;
+       markup_from[i] = "&:-)"; markup_to[i] = "\x13"; ++i;
+       markup_from[i] = "&:-("; markup_to[i] = "\x14"; ++i;
+       markup_from[i] = "&x-P"; markup_to[i] = "\x15"; ++i;
+       markup_from[i] = "&:-/"; markup_to[i] = "\x16"; ++i;
+       markup_from[i] = "&:-D"; markup_to[i] = "\x17"; ++i;
+       markup_from[i] = "&<<"; markup_to[i] = "\x18"; ++i;
+       markup_from[i] = "&>>"; markup_to[i] = "\x19"; ++i;
+       markup_from[i] = "&dot"; markup_to[i] = "\x1a"; ++i;
+       markup_from[i] = "&^_"; markup_to[i] = "\x1b"; ++i;
+       markup_from[i] = "&ysplat"; markup_to[i] = "\x1c"; ++i;
+       markup_from[i] = "&-]"; markup_to[i] = "\x1d"; ++i;
+       markup_from[i] = "&--"; markup_to[i] = "\x1e"; ++i;
+       markup_from[i] = "&[-"; markup_to[i] = "\x1f"; ++i;
+       markup_from[i] = "&s<"; markup_to[i] = "\x2c"; ++i;
+       markup_from[i] = "&s>"; markup_to[i] = "\x2e"; ++i;
+       markup_from[i] = "&<-"; markup_to[i] = "\x7f"; ++i;
+       markup_from[i] = "&[="; markup_to[i] = "\x80"; ++i;
+       markup_from[i] = "&=="; markup_to[i] = "\x81"; ++i;
+       markup_from[i] = "&=]"; markup_to[i] = "\x82"; ++i;
+       markup_from[i] = "&r!"; markup_to[i] = "\x84"; ++i;
+       markup_from[i] = "&|o|"; markup_to[i] = "\x85"; ++i;
+       markup_from[i] = "&|u|"; markup_to[i] = "\x86"; ++i;
+       markup_from[i] = "&|i|"; markup_to[i] = "\x87"; ++i;
+       markup_from[i] = "&|c|"; markup_to[i] = "\x88"; ++i;
+       markup_from[i] = "&[c]"; markup_to[i] = "\x89"; ++i;
+       markup_from[i] = "&[n]"; markup_to[i] = "\x8a"; ++i;
+       markup_from[i] = "&[]"; markup_to[i] = "\x8b"; ++i;
+       markup_from[i] = "&r?"; markup_to[i] = "\x8c"; ++i;
+       markup_from[i] = "&|>"; markup_to[i] = "\x8d"; ++i;
+       markup_from[i] = "&splat0"; markup_to[i] = "\x8e"; ++i;
+       markup_from[i] = "&splat1"; markup_to[i] = "\x8f"; ++i;
+       markup_from[i] = "&[["; markup_to[i] = "\x90"; ++i;
+       markup_from[i] = "&]]"; markup_to[i] = "\x91"; ++i;
+       markup_from[i] = "&splat2"; markup_to[i] = "\x9a"; ++i;
+       markup_from[i] = "&)("; markup_to[i] = "\x9b"; ++i;
+       markup_from[i] = "&splat3"; markup_to[i] = "\x9c"; ++i;
+       markup_from[i] = "&(."; markup_to[i] = "\x9d"; ++i;
+       markup_from[i] = "&.."; markup_to[i] = "\x9e"; ++i;
+       markup_from[i] = "&.)"; markup_to[i] = "\x9f"; ++i;
+       markup_from[i] = "&<|"; markup_to[i] = "\xff"; ++i;
+}
+
+string GenericCommand_markup(string s2)
+{
+       float red, ccase, i, j;
+       string s, s3;
+
+       GenericCommand_markup_init();
+
+       s = "";
+
+       red = 0;
+       ccase = 0;
+       for(i = 0; i < strlen(s2); ++i)
+       {
+               for(j = 0; j < NUM_MARKUPS; ++j)
+               {
+                       s3 = substring(s2, i, strlen(markup_from[j]));
+                       if (s3 == markup_from[j])
+                       {
+                               s = strcat(s, markup_to[j]);
+                               i += strlen(markup_from[j]) - 1;
+                               break;
+                       }
+               }
+
+               if(j == NUM_MARKUPS)
+               {
+                       if(substring(s2, i, 2) == "&&")
+                       {
+                               s = strcat(s, strconv(ccase, red, red, "&"));
+                               ++i;
+                       }
+                       else if(substring(s2, i, 2) == "&d")
+                       {
+                               red = 2;
+                               ccase = 0;
+                               ++i;
+                       }
+                       else if(substring(s2, i, 2) == "&a")
+                       {
+                               red = 2;
+                               ccase = 2;
+                               ++i;
+                       }
+                       else if(substring(s2, i, 2) == "&n")
+                       {
+                               red = 0;
+                               ccase = 0;
+                               ++i;
+                       }
+                       else
+                               s = strcat(s, strconv(ccase, red, red, substring(s2, i, 1)));
+               }
+       }
+
+       return s;
+}
diff --git a/qcsrc/common/command/markup.qh b/qcsrc/common/command/markup.qh
new file mode 100644 (file)
index 0000000..331e2a5
--- /dev/null
@@ -0,0 +1,9 @@
+// =========================================================
+//  Markup chat characters command code, reworked by Samual
+//  Last updated: December 28th, 2011
+// =========================================================
+
+#define NUM_MARKUPS    41
+float markup_init;
+string markup_from[NUM_MARKUPS];
+string markup_to[NUM_MARKUPS];
index 0af6bebe5566538c31d32821194acf1405dfadf9..1f70e0e7be2f0ce5aef5c87d036d36c696e3122c 100644 (file)
@@ -15,6 +15,7 @@ oo/base.h
 ../common/mapinfo.qh
 ../common/campaign_common.qh
 ../common/items.qh
+../common/command/markup.qh
 ../common/command/rpn.qh
 ../common/command/generic.qh
 ../common/command/shared_defs.qh
@@ -31,6 +32,7 @@ oo/implementation.h
        classes.c
 
 ../common/util.qc
+../common/command/markup.qc
 ../common/command/rpn.qc
 ../common/command/generic.qc
 command/menu_cmd.qc
index 0280a7f8a81e1062c1ec0ff3d03c60176cf49054..0a4c296cc445ac4b1e46e2ec3908019ece2e1de1 100644 (file)
@@ -17,6 +17,7 @@ sys-post.qh
 ../common/items.qh
 ../common/explosion_equation.qh
 ../common/urllib.qh
+../common/command/markup.qh
 ../common/command/rpn.qh
 ../common/command/generic.qh
 ../common/command/shared_defs.qh
@@ -147,6 +148,7 @@ campaign.qc
 ../common/campaign_setup.qc
 ../common/urllib.qc
 
+../common/command/markup.qc
 ../common/command/rpn.qc
 ../common/command/generic.qc
 command/common.qc