Bug 3114 - clean up ClientCommand
Status: RESOLVED FIXED
Alias: None
Product: Tremulous
Classification: Unclassified
Component: Misc
Version: unspecified
Hardware: All All
: P3 minor
Assignee: Tremulous Bugs
QA Contact:
URL:
Depends on:
Blocks: 3089
 
Reported: 2007-05-20 21:54 EDT by M. Kristall
Modified: 2007-06-12 17:32:39 EDT
0 users

See Also:


Attachments
ClientCommand (first try) (14.55 KB, patch)
2007-05-20 22:13 EDT, M. Kristall
ClientCommand (second try) (16.41 KB, patch)
2007-05-22 02:59 EDT, M. Kristall
ClientCommand (third try) (17.08 KB, patch)
2007-05-27 04:24 EDT, M. Kristall
ClientCommand (fourth) (17.23 KB, patch)
2007-06-10 15:42 EDT, M. Kristall
updated for r945 (17.07 KB, patch)
2007-06-12 17:01 EDT, M. Kristall

Description M. Kristall 2007-05-20 21:54:23 EDT
ClientCommand is long and only getting longer. Also, for no apparent reason, new commands keep getting added inconsistently.
Comment 1 M. Kristall 2007-05-20 22:13:40 EDT
Created attachment 1350 [details]
ClientCommand (first try)

This patch is entirely untested, but it does compile. Some of the stuff should be moved around a little for a final version of this.

This changes all Cmd_*_f commands to accept only a single arg. Some functions
had to be modified to work without extra args.

This does a couple extra things:
* Cmd_Follow_f should not be used elsewhere for toggling. A new function,
  G_ToggleFollow, was added for that. /toggle without any arguments still
  functions the same.
* CheatsOk was removed. This check is done in ClientCommand.
* I removed the distinction between /destroy and /deconstruct. Since /destroy
  can only be used with cheats enabled, I figure it should probably be entirely
  removed. (I kept it because the function is called Cmd_Destroy_f.)

What was the arg0 stuff in Cmd_Say_f for? It wasn't used and didn't look useful,
so I removed it.
Comment 2 M. Kristall 2007-05-20 22:22:08 EDT
I forgot to mention that I removed the /test command (didn't do anything anyway).
I also just noticed that I reversed /ignore and /unignore. It should be:
ignore = !Q_stricmp( cmd, "ignore" );
(the '!' was missing).
I should also make /follow(next|prev) consistent with /say(_team)?:
int dir = 1;
...
if( Q_stricmp( args, "follownext" ) )
  dir = -1
(after all, ternary conditions are usually really ugly -- that one is no exception)

Any other problems?
Comment 3 M. Kristall 2007-05-22 02:59:08 EDT
Created attachment 1357 [details]
ClientCommand (second try)

Updated for revision 940. Fixed the issues in comment #2.
Made the "give_all" test in Cmd_Give_f consistent as well.
Removed the PTE_NONE (else) condition from Cmd_CallTeamVote_f and Cmd_TeamVote_f and avoided a stupid gcc warning.
Removed the PTE_NONE condition from Cmd_Class_f.

ScoreboardMessage is used instead of Cmd_Score_f (since that's all Cmd_Score_f did anyway).

I think this is at least in a test-worthy state ;-) Also, any other redundant tests that can be removed would be nice.
Comment 4 M. Kristall 2007-05-27 04:24:22 EDT
Created attachment 1377 [details]
ClientCommand (third try)

Minor update:
* Changes all Cmd_Score_f to ScoreboardMessage
* Properly returns if an admin command is used
Comment 5 M. Kristall 2007-06-03 06:11:29 EDT
Comment on attachment 1377 [details]
ClientCommand (third try)

>-  cmd = ( ignore ) ? "ignore" : "unignore";
>+  trap_Argv( 1, cmd, sizeof( cmd ) );
>+  if( Q_stricmp( cmd, "ignore" ) == 0 )
>+    ignore = qtrue;
> 
that should be
trap_Argv( 0, cmd, sizeof( cmd ) );
Comment 6 M. Kristall 2007-06-10 15:42:51 EDT
Created attachment 1405 [details]
ClientCommand (fourth)

Changes the names for a couple flags and moves stuff where it should probably be.
Anything else that needs changing?
Comment 7 M. Kristall 2007-06-12 17:01:44 EDT
Created attachment 1413 [details]
updated for r945

I don't think this is any different from attachment 1405 [details] other than fixing a bad search & replace
Comment 8 M. Kristall 2007-06-12 17:32:39 EDT
committed at r946