Game Development Community

dev|Pro Game Development Curriculum

Indent "Loading compiled script.." lines by execDepth

by Orion Elenzil · 11/13/2006 (4:42 pm) · 4 comments

You know the lines in your console.log which read "Loading compiled script " ?
And you know how it's sometimes hard to tell from those which scripts have exec()'d others ?
This mod simply indents each line by the current execDepth.

easiest to describe by example;
what used to be this:
Loading compiled script projects/common/characters/initDatablocks.cs.
Loading compiled script projects/common/characters/emote.cs.
Loading compiled script projects/common/characters/conversation.cs.
Loading compiled script projects/common/characters/f_player/f_player.cs.
Loading compiled script projects/common/characters/m_player/m_player.cs.
Loading compiled script projects/common/characters/NPC/init.cs.
Loading compiled script projects/common/characters/NPC/bouncer1/npc_bouncer1.cs.
Loading compiled script projects/common/characters/NPC/dj1/npc_dj1.cs.
Loading compiled script projects/common/characters/NPC/dj2/npc_dj2.cs.
Loading compiled script projects/common/characters/playerDB.cs.
Loading compiled script intersection/server/scripts/aiPlayer.cs.


is now this:
.Loading compiled script projects/common/characters/initDatablocks.cs.
..Loading compiled script projects/common/characters/emote.cs.
..Loading compiled script projects/common/characters/conversation.cs.
..Loading compiled script projects/common/characters/f_player/f_player.cs.
..Loading compiled script projects/common/characters/m_player/m_player.cs.
..Loading compiled script projects/common/characters/NPC/init.cs.
...Loading compiled script projects/common/characters/NPC/bouncer1/npc_bouncer1.cs.
...Loading compiled script projects/common/characters/NPC/dj1/npc_dj1.cs.
...Loading compiled script projects/common/characters/NPC/dj2/npc_dj2.cs.
..Loading compiled script projects/common/characters/playerDB.cs.
.Loading compiled script intersection/server/scripts/aiPlayer.cs.



engine/console/consoleFunctions.cc
near the top of ConsoleFunction(exec, bool, ...),
add these lines:
char       execDepthToken[]    = ".";
   char       execDepthBuf  [256] = "";


down towards the bottom of the same function,
replace this line:
Con::printf("%sLoading compiled script %s.", execDepthBuf, scriptFileName);
with these lines:
execDepthBuf[0] = '[[60c1d2d3d2084]]';
      for (S32 n = 0; n < execDepth; n++)
      {
         dStrncat(execDepthBuf, execDepthToken,  sizeof(execDepthBuf) - (sizeof(execDepthToken) - 1) * n);
      }
      Con::printf("%sLoading compiled script %s.", execDepthBuf, scriptFileName);


.. that's it!

note i originally was using "the dot" as the indent character,
but the GG site ate the resource when i did that, so i changed it to a plain old period.
- thanks to Mike Perry and Josh Dallman for pointing out the problem!

#1
11/01/2006 (5:24 pm)
Very nice resource. Already added it into my build to help me clean up Ars Moriendi, so you got a spot on the "Thanks Page" of the game =)

Glad to help out btw.
#2
11/24/2006 (6:25 am)
Btw, since Con::printf is just a wrapper around the standard printf, you could also do:
Con::printf("%-*sLoading compiled script %s.", execDepth - 1, ".", scriptFileName);

And achieve the same results.
#3
11/24/2006 (2:12 pm)
wow! awesome, thanks Gregory. I've done it my hacky way for years and never realized printf could do that.
#4
03/10/2007 (7:50 pm)
Thanx Gregory !