Guida C++ Chat Globale

Stato
Discussione chiusa ad ulteriori risposte.

Mr.Kasch Aka 907

Utente Emerald
14 Maggio 2012
928
57
174
411
Non avendo trovato nulla su inforge riguardante la chat globale nei source ho deciso di postare una guida riscritta in italiano. :)

Prima di tutto andiamo nella cartella "Game" all'interno dei source:
/src_server/game/src/
Cerchiamo il file "input_p2p.cpp"
In cima aggiungiamo (dopo l'elenco)
Codice:
#include "threeway_war.h"

extern bool global_chat;

Screen:
ub7F3Pc.png

Ora cerchiamo "struct FuncShout" e sostituiamo
Codice:
if (!d->GetCharacter() || (d->GetCharacter()->GetGMLevel() == GM_PLAYER && d->GetEmpire() != m_bEmpire))
   return;
Con:
Codice:
if(global_chat)
   {
     if (!d->GetCharacter())
       return;
   }else {
     if (!d->GetCharacter() || (d->GetCharacter()->GetGMLevel() == GM_PLAYER && d->GetEmpire() != m_bEmpire))
       return;
   }

Screen:
pbTiIlo.png

E con questo file abbiamo finito, ora apriamo "input_main.cpp" e cerchiamo:
Codice:
ch->SetLastShoutPulse(thecore_heart->pulse);

Sotto esso aggiungiamo: (Contiene già la modifica per lo Staff)
Codice:
     if(global_chat)
       {
         char buf[256];
         char chatbuf_global[CHAT_MAX_LEN + 1];
         const BYTE char_empire = ch->GetEmpire();
         if (ch->GetGMLevel() != GM_PLAYER)
         {
           strlcpy(buf, LC_TEXT("Staff"), sizeof(buf));
           std::string staff_color = "|cFFFFC700|H|h[";
           staff_color += buf;
           staff_color += "]|cFFA7FFD4|H|h";
           sprintf(chatbuf_global, "%s %s", staff_color.c_str(), chatbuf);
         }
         else if (char_empire == 1)
         {
           strlcpy(buf, LC_TEXT("Shinsoo"), sizeof(buf));
           std::string kingdom_red = "|cFFff0000|H|h[";
           kingdom_red += buf;
           kingdom_red += "]|cFFA7FFD4|H|h";
           sprintf(chatbuf_global, "%s %s", kingdom_red.c_str(), chatbuf);
         }
         else if (char_empire == 2)
         {
           strlcpy(buf, LC_TEXT("Chunjo"), sizeof(buf));
           std::string kingdom_yel = "|cFFFFFF00|H|h[";
           kingdom_yel += buf;
           kingdom_yel += "]|cFFA7FFD4|H|h";
           sprintf(chatbuf_global, "%s %s", kingdom_yel.c_str(), chatbuf);
         }
         else if (char_empire == 3) {
           strlcpy(buf, LC_TEXT("Jinno"), sizeof(buf));
           std::string kingdom_blue = "|cFF0080FF|H|h[";
           kingdom_blue += buf;
           kingdom_blue += "]|cFFA7FFD4|H|h";
           sprintf(chatbuf_global, "%s %s", kingdom_blue.c_str(), chatbuf);
         }
        
         TPacketGGShout p;

         p.bHeader = HEADER_GG_SHOUT;
         p.bEmpire = char_empire;
         strlcpy(p.szText, chatbuf_global, sizeof(p.szText));
         P2P_MANAGER::instance().Send(&p, sizeof(TPacketGGShout));
         SendShout(chatbuf_global, ch->GetEmpire());
         return (iExtraLen);
       }

Screen:
img
E anche qui abbiamo finito, apriamo "config.cpp"
Cerchiamo:
Codice:
int gPlayerMaxLevel = 99;

Aggiungiamo sotto:
Codice:
bool global_chat = false;

Screen:
8k8bgyN.png

Ora cerchiamo:
Codice:
     TOKEN("max_level")
     {
       str_to_number(gPlayerMaxLevel, value_string);

       gPlayerMaxLevel = MINMAX(1, gPlayerMaxLevel, PLAYER_MAX_LEVEL_CONST);

       fprintf(stderr, "PLAYER_MAX_LEVEL: %d\n", gPlayerMaxLevel);
     }
E sotto aggiungiamo:
Codice:
     TOKEN("global_chat")
     {
       int flag = 0;
       str_to_number(flag, value_string);
       if (1 == flag)
       {
         global_chat = true;
         fprintf(stderr, "GLOBAL_CHAT: %i\n", flag);
       }
     }

Screen:
JhbNyT3.png

E con i source abbiamo finito (Salviamo tutto e compiliamo)

Ora andiamo in share/locale/italy/locale_string.txt
All'interno del "locale_string.txt" aggiungiamo:
Codice:
"Jinno";
"Jinno";
"Chunjo";
"Chunjo";
"Shinsoo";
"Shinsoo";
"Staff";
"Team";
PS:
"Jinno"; <--- Corrisponde a quello nei source
"Jinno"; <--- Corrisponde a ciò che volete che venga scritto in gioco

Ora basta inserire nei "CONFIG"
Codice:
global_chat: 1
Ed il gioco è fatto :)

rA513eD.png


Fonti: Metin2D*v, Denis, Despero, Shisui
 
Stato
Discussione chiusa ad ulteriori risposte.