Author Topic: Aineko's Guide to Client Modding  (Read 19946 times)

aineko

  • Traveller
  • *
  • Posts: 46
    • View Profile
Aineko's Guide to Client Modding
« on: February 16, 2004, 06:48:15 pm »
After Mogura\'s Guide to Client Customisation. Here\'s my guide to Client Modding.

!! You have to compile PlaneShift from source !!

!! Don\'t blame me if you screw up. You do it at your own risk !!

\" !>\" means that a line of code is inserted.
\"
If you like my mods and one of the developer finds a little free time, he might compile it and put it to the updater ;)

I think we should start now.


# Mod 1

If you\'d like the have a logfile of the ingame chat, do the following. This is very hand to dump the buddy list :)

File: planeshift\\src\\client\\aws\\pscommwindow.cpp
-----------------------------------------------

019 #include
 !> #include
020
021 // CS INCLUDES

--
//Log of the SystemWindow

129             if (psContain(noCaseMsg,systemTriggers)){
130                 colour = psengine->GetG2D()->FindRGB(255,255,0);
131             }
132            
 !>             ofstream fp_out(\"chat.log\",ios::app);
 !>
 !>             if (fp_out.is_open())
 !>             {
 !>                 fp_out << buff;
 !>                 fp_out.close();
 !>             }
133            
134             systemTextBox->AddLine(buff, colour);

---
//Log of the ChatWindow

285     if ( buff[0] )
 !>     {
286         chatTextBox->AddLine(buff, colour);
287            
 !>         ofstream fp_out(\"chat.log\",ios::app);
 !>
 !>         if (fp_out.is_open())
 !>         {
 !>             fp_out << buff;
 !>             fp_out.close();
 !>         }
 !>     }
287 }

-----------------------------------------------


# Mod 2

With this little trick you can spice up the colors of your chat window.

File: planeshift\\src\\client\\aws\\pscommwindow.h
-----------------------------------------------

122     int triggerColour;
123
 !>     int sayColour;
 !>
 !>     int meColour;
 !>
 !>     int guildColour;
123 }

-----------------------------------------------

File: planeshift\\src\\client\\aws\\pscommwindow.cpp
-----------------------------------------------

206     if ( !havePlayerName )
207     {
208         csRef psengine = CS_QUERY_REGISTRY(objreg, iPSEngine);
209         noCasePlayerName.Replace(psengine->GetCelClient()->GetMainActor()->GetName());
210         noCasePlayerName.strlwr(); // Create lowercase string
211         chatTriggers.Push(noCasePlayerName);
212         havePlayerName = true;
213         playerColour = psengine->GetG2D()->FindRGB(255,35,35);
214         triggerColour = psengine->GetG2D()->FindRGB(204,255,0);
215
 !>         sayColour = psengine->GetG2D()->FindRGB(90,205,255);
 !>         meColour = psengine->GetG2D()->FindRGB(45,103,255);
 !>         guildColour = psengine->GetG2D()->FindRGB(60,200,0);
215     }
216
217     switch( msg.iChatType )
218     {
219     case CHAT_GROUP:
220     case CHAT_SHOUT:
221    {
222        cs_snprintf(buff,1024,\"%s shouts: %s\\n\",
223                (const char *)msg.sPerson,(const char *)msg.sText);
224        break;
225    }
226    case CHAT_GUILD:
227    case CHAT_AUCTION:
228    {
229        cs_snprintf(buff,1024,\"%s from %s: %s\\n\",pType,
230                (const char *)msg.sPerson,(const char *)msg.sText);
 !>         colour = guildColour;
221        break;
232    }
233
234     case CHAT_SAY:
235     {
236         cs_snprintf(buff,1024,\"%s says: %s\\n\",
237                 (const char *)msg.sPerson,(const char *)msg.sText);
 !>         colour = sayColour;
238         break;
239     }
240
241     case CHAT_ME:
242     {
243         cs_snprintf(buff,1024,\"%s %s\\n\",
244                 (const char *)msg.sPerson,(const char *)msg.sText);
 !>         colour = meColour;
245         break;
246     }

-----------------------------------------------


# Mod 3

Did you ever wonder what time it is? Let\'s add a ingame clock.

File: planeshift\\src\\client\\psengine.cpp
-----------------------------------------------

505         psUserCmdMessage cmdmsg(\"/online\");
506         netmanager->GetMsgHandler()->SendMessage(cmdmsg.msg);
507        
 !>         modehandler->IsReady = true;
 !>    
508         return true;

-----------------------------------------------

hmm, I know it\'s not nice to mess with variables that arn\'t yours, but call my lazy :)


File: planeshift\\src\\client\\modehandler.h
-----------------------------------------------

112     void CheckNewSectorRain(iSector *newsector);
113
 !>     bool IsReady;
 !>    
113 };

-----------------------------------------------

File: planeshift\\src\\client\\modehandler.cpp
-----------------------------------------------

080     LoadLightingLevels();
081    
 !>     IsReady = false;
081 }

---

373             printf(\"The time is now %d o\'clock.\\n\",msg.value);
373    
 !>             if (IsReady)
 !>             {
 !>                 char tmp[256];
 !>                 sprintf(tmp, \"The time is now %d o\'clock.\",msg.value);
 !>                 psSystemMessage sys(0,MSG_INFO,tmp);
 !>                 msghandler->AddToLocalQueue(sys.msg);
 !>             }
 !>
375             if (msg.value > lights.Length() )


-----------------------------------------------


# Mod 4

Aren\'t you tired of typing \"/tell personwithincrediblelongname hello\" ?
Just set /talkto and everything you type will be told to that person ;)

File: planeshift\\src\\client\\aws\\pscommwindow.h
-----------------------------------------------

122     int triggerColour;
123
 !>     char* pTalkPerson;
 !>
 !>     bool useTalkto;
123 };

-----------------------------------------------

File: planeshift\\src\\client\\aws\\pscommwindow.cpp
-----------------------------------------------

065     systemTriggers.Push(\"server admin\");
066
 !>     pTalkPerson = \"\";
 !>     useTalkto = false;
 !>    
066 }

---

076     cmdsource->Subscribe(\"/say\",
077               \"Talk to the people in your immediate vicinity.\",
078               true,this);
 !>     cmdsource->Subscribe(\"/tlk\", \"Ignore that. You shouldn\'t see it anyway ;)\", false,this);
 !>     cmdsource->Subscribe(\"/talkto\",\"Set who to talk to. ;)\",CmdHandler::VISIBLE_TO_USER,this);
079     cmdsource->Subscribe(\"/shout\",\"Talk to people in your sector.\",CmdHandler::VISIBLE_TO_USER,this);

---

297     if ( buff[0] != \'/\' )
298     {
299         pPerson = \"\";
300         pText = buff;
300         *(pText-1) = 0;
300         chattype = CHAT_SAY;
300     }
 !>     else if ( !strncmp(buff+1, \"tlk \", 4 ))
 !>     {
 !>         if (useTalkto)
 !>         {
 !>             pPerson = pTalkPerson;
 !>             pText = buff + 5;
 !>             chattype = CHAT_TELL;
 !>         }
 !>         else
 !>         {
 !>             pPerson = \"\";
 !>             pText = buff + 5;
 !>             chattype = CHAT_SAY;
 !>         }
 !>     }
 !>     else if ( !strncmp(buff+1, \"talkto \", 7))
 !>     {
 !>         pTalkPerson = csStrNew(buff + 8);
 !>         useTalkto = true;
 !>
 !>         delete[] buff;
 !>         return NULL;
 !>     }
 !>     else if ( !strncmp(buff+1, \"talkto\", 6))
 !>     {
 !>         useTalkto = false;
 !>     }
304     else if ( !strncmp(buff+1, \"say \", 4))

---

403             char* tmp = new char[strlen(Str)+7];
404             tmp[0] = \'/\';
  !>             tmp[1] = \'t\';
  !>             tmp[2] = \'l\';
  !>             tmp[3] = \'k\';
408             tmp[4] = \' \';

-----------------------------------------------


# Mod 5

Wanna disable the sound forever? Maybe because you\'re running winamp in the background? or WinTV?

File: planeshift\\src\\client\\sound\\pssoundmngr.cpp
-----------------------------------------------

076     SCF_CONSTRUCT_IBASE (iParent);
077
  !>     soundEnabled = false;
  !>     musicEnabled = false;
080
081     eventHandler = NULL;

-----------------------------------------------


# Mod 6

Are you tired of holding down the shift-key to run? Then let\'s make it stick. press L (or what ever you set in the keys.xml)

File: planeshift\\src\\common\\psbehave\\psbehave.cpp
-----------------------------------------------

243                     autorun    = false,
244                     running    = false,
 !>                     lockrun    = false,
245                     hyperrun   = false;

---

291     else if (!strcmp (msg_id+11, \"autorun1\")) // toggle switch not only while keydown
292     {
293         if (autorun == running)
294         {
295                autorun = (autorun)?false:true;
296             running = autorun;
297         }
298     }
 !>     else if (!strcmp (msg_id+11, \"lockrun1\")) // toggle switch not only while keydown
 !>     {
 !>         if (lockrun == running)
 !>         {
 !>             lockrun = (lockrun)?false:true;
 !>             running = lockrun;
 !>         }
 !>     }
299     else if (!strcmp (msg_id+11, \"run1\") && !autorun)
300     {
301         // If run is turned on by holding down a key
  !>         if (!running && !autorun && !lockrun)
303             running = true;
304     }
305     else if (!strcmp (msg_id+11, \"run0\") && !autorun)
306     {
  !>         if (!running && !autorun && !lockrun)
308             running = false;
309     }

-----------------------------------------------

File: planeshift\\keys.xml
-----------------------------------------------

016        
 !>        
017

-----------------------------------------------


# Mod 7

Take a screenshot by simply pressing P (or what ever you set in the keys.xml)

File: planeshift\\src\\common\\psbehave\\psbehave.cpp
-----------------------------------------------

031 #include
032
 !> #include
 !> #include
 !> #include
 !> #include
 !> #include \"psengine.h\"
033
034 #include

---

263         if (!pccam)
264             return false;
265
 !>         if (!strcmp (msg_id+11, \"screenshot1\"))
 !>             {
 !>                 CaptureScreen();
 !>                 return false;
 !>             }
266
267         if (!strcmp (msg_id+11, \"forward1\"))

---

598         mouselook_first_time = false;
599     }
600 }
601
 !> void psBehaviourActor::CaptureScreen()
 !> {
 !>
 !>   char name[255];
 !>   sprintf(name, \"/this/screenshot/%d.jpg\", time(NULL));
 !>
 !>   csRef G2D = CS_QUERY_REGISTRY(object_reg, iGraphics2D);
 !>   if (!G2D) return;
 !>
 !>   csRef VFS = CS_QUERY_REGISTRY (object_reg, iVFS);
 !>   if (!VFS) return;
 !>
 !>   csRef img (csPtr (G2D->ScreenShot ()));
 !>   if (!img) return;
 !>
 !>   csRef imageio (CS_QUERY_REGISTRY (object_reg, iImageIO));
 !>   if (!imageio) return;
 !>
 !>   csRef db (imageio->Save (img, \"image/jpg\", \"progressive\"));
 !>   if (!db) return;
 !>
 !>   if (VFS->WriteFile(name, (const char*)db->GetData(), db->GetSize()))
 !>   {
 !>     csRef psengine = CS_QUERY_REGISTRY(object_reg, iPSEngine);
 !>     if (!psengine) return;
 !>     char tmp[255];
 !>     sprintf(tmp, \"Screenshot taken.\\n\");
 !>    psSystemMessage sys(0,MSG_INFO,tmp);
 !>     psengine->GetMsgHandler()->AddToLocalQueue(sys.msg);
 !>   }
 !> }
602
603 psBehaveTest::psBehaveTest()

-----------------------------------------------

File: planeshift\\src\\common\\psbehave\\psbehave.cpp
-----------------------------------------------

127     csVector3 defFollowPos, defLookatPos, defFirstPos;
128
 !>     void CaptureScreen ();
129 };

-----------------------------------------------

File: planeshift\\keys.xml
-----------------------------------------------

016      
 !>        
017  

-----------------------------------------------
« Last Edit: February 16, 2004, 07:06:42 pm by aineko »

Draklar

  • Forum Legend
  • *
  • Posts: 4422
    • View Profile
(No subject)
« Reply #1 on: February 16, 2004, 07:08:41 pm »
nice job Aineko. Too bad I won\'t be able to use it :P
btw: you should disable smileys in that post :P
AKA Skald

lynx_lupo

  • Veteran
  • *
  • Posts: 1431
  • Sorbus aria!
    • View Profile
    • Linux pri nas
(No subject)
« Reply #2 on: February 16, 2004, 07:23:11 pm »
Nice! :tup:
Although, auto-run is already there. ?(
"Amor sceleratus habendi"- Ovid
"First they ignore you, then they laugh at you, then they fight you, then you eat them." -Godzilla

Draklar

  • Forum Legend
  • *
  • Posts: 4422
    • View Profile
(No subject)
« Reply #3 on: February 16, 2004, 07:28:44 pm »
yea, but autorun is like holding shift AND w/up-arrow
maybe this thingy works like holding shift only
AKA Skald

aineko

  • Traveller
  • *
  • Posts: 46
    • View Profile
(No subject)
« Reply #4 on: February 16, 2004, 07:32:50 pm »
Exactly, draklar, you got the point :D

aircows

  • Traveller
  • *
  • Posts: 19
    • View Profile
(No subject)
« Reply #5 on: February 16, 2004, 08:35:29 pm »
Very cool.  You should make one of those source patches that goes in and does these changes for the source tree.  I know it\'s possible, I just don\'t know where, I\'ve done it before in Gentoo and when I was compiling a kernel for Yellow Dog Linux.  I don\'t know how you\'d do it in Windows, but I\'m assuming a simple patch like that shouldn\'t be a problem in Linux or OS X.
==============================================
|||  And on the 8th day, God created the Mac, and it was good.  |||
==============================================

Moogie

  • Forum Legend
  • *
  • Posts: 4551
  • Artist/Flash Animator
    • View Profile
(No subject)
« Reply #6 on: February 16, 2004, 09:05:20 pm »
Great work, Aineko! :)

*brings out the glue*

Stickied. :D

aineko

  • Traveller
  • *
  • Posts: 46
    • View Profile
(No subject)
« Reply #7 on: February 16, 2004, 09:49:33 pm »
Thanks Mogura

Yay, it\'s sticky. Not bad for the 4th post i\'d say :)

aircows: you bet, i don\'t know it either :D

I just wonder who actually uses my mods :)

aircows

  • Traveller
  • *
  • Posts: 19
    • View Profile
(No subject)
« Reply #8 on: February 16, 2004, 10:44:27 pm »
and after about 2 minutes of googling.  The commands to do that are \"diff\" and \"patch\".  diff to creat the diff-file, and patch to apply the diff-file to the source tree.
==============================================
|||  And on the 8th day, God created the Mac, and it was good.  |||
==============================================

aineko

  • Traveller
  • *
  • Posts: 46
    • View Profile
(No subject)
« Reply #9 on: February 16, 2004, 10:57:10 pm »
sure, with linux :) but not on windows. the only thing I have is windiff from the msvs.

Anyway, I\'ll merge all patches (but the sound one) in the files and distribute the changed files.

Maybe on of the developers might even find a few minutes of time to compile it and put it in the updater :D

Most ppl probably won\'t be able to compile PS anyway :(

CadRipper

  • Hydlaa Citizen
  • *
  • Posts: 487
  • merry troublemaker
    • View Profile
(No subject)
« Reply #10 on: February 17, 2004, 08:45:34 am »
Great work, Aineko, I knew you\'d post it someday  ;)

Now the next mod should be a one-by-one /give, to work around the new bug introduced since Ezman :D

For those who would like the flexibility and power of Unix/Linux shells under Windows, try Cygwin (http://www.cygwin.com/ ). It\'s very handy.

If I remember well, the best is to take the sources from here : http://www.planeshift.it/download_source.html : PSV0.2.010.Snapshot.zip. Don\'t take them from CVS !

Niber

  • Hydlaa Citizen
  • *
  • Posts: 290
    • View Profile
(No subject)
« Reply #11 on: February 17, 2004, 12:31:27 pm »
Rock on!
I especially like the clock  :]  
I haven\'t tryed it though but it sounds cool.
Put the pot down, no dont take another puff!, put it down. Thank you.

aineko

  • Traveller
  • *
  • Posts: 46
    • View Profile
(No subject)
« Reply #12 on: February 17, 2004, 07:34:40 pm »
Ok, forget the patches, here are the changed files: (i hope there is rar for linux)

http://www.freewebs.com/aineko/planeshift-src.rar


For those who can compile it, a binary distro:

http://www.freewebs.com/aineko/planeshift-bin.rar

! Warning !
! You use it at your own risk !
! I might not be stable !
! so don\'t blame me !

just extract the file into your PlaneShift folder.

to undo, run the updater

Hadfael

  • Hydlaa Citizen
  • *
  • Posts: 241
    • View Profile
mirror for binaries
« Reply #13 on: February 18, 2004, 08:58:31 pm »
for a faster download of the 2,91MB binaries
http://perso.wanadoo.fr/locutus.borg/planeshift-bin.rar.


http://perso.wanadoo.fr/locutus.borg/planeshift-bin.zip>
« Last Edit: February 19, 2004, 08:56:07 pm by Hadfael »

Uyaem

  • Hydlaa Notable
  • *
  • Posts: 747
    • View Profile
(No subject)
« Reply #14 on: February 19, 2004, 12:17:26 am »
THX, Golmir. Expected 40mins for 3MB download reminded me too much of \"the old times\" ;)
The internet is "the terrorists'" most important weapon, they say.
Wrong.
Fear is their most important weapon.
Ours is our freedom.