~ubuntu-branches/ubuntu/lucid/warzone2100/lucid

« back to all changes in this revision

Viewing changes to src/cheat.c

  • Committer: Bazaar Package Importer
  • Author(s): Christoph Egger, Paul Wise, Christoph Egger
  • Date: 2009-06-29 17:12:52 UTC
  • mfrom: (1.1.11 upstream) (2.1.7 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090629171252-5ddnlfg3zfchrega
Tags: 2.2.1+dfsg1-1
[ Paul Wise ]
* New upstream release (Closes: #534962)
* Adjust the flex build-depends to take account of the conflict
  with all the versions of flex 2.5.34 (LP: #372872)
* Make the -music Recommends more strict, 2.1 music doesn't work
  with 2.2.
* Upstream moved the downloads to sourceforge, update the watch file
* Bump Standards-Version, no changes needed
* Drop use of dh_desktop since it no longer does anything
* Recommend the new warzone2100-video package, version 2.2 or similar
* Mention the warzone2100 crash reports in the -dbg package description

[ Christoph Egger ]
* Replace CC-2.0 graphic from cybersphinx, create a new tarball
* Add myself to uploaders

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
        This file is part of Warzone 2100.
3
3
        Copyright (C) 1999-2004  Eidos Interactive
4
 
        Copyright (C) 2005-2007  Warzone Resurrection Project
 
4
        Copyright (C) 2005-2009  Warzone Resurrection Project
5
5
 
6
6
        Warzone 2100 is free software; you can redistribute it and/or modify
7
7
        it under the terms of the GNU General Public License as published by
24
24
/* Alex M 19th - Jan. 1999 */
25
25
 
26
26
#include "lib/framework/frame.h"
 
27
#include "lib/framework/string_ext.h"
 
28
#include "lib/exceptionhandler/dumpinfo.h"
27
29
#include "cheat.h"
28
30
#include "console.h"
29
31
#include "keybind.h"
34
36
        void (*function)(void); // pointer to void* function
35
37
} CHEAT_ENTRY;
36
38
 
 
39
bool Cheated = false;
37
40
static CHEAT_ENTRY cheatCodes[] =
38
41
{
39
42
//      {"VQKZMY^\\Z",kf_ToggleOverlays},//interface
44
47
//      {"PJKSVQZ,",kf_ToggleOutline},
45
48
//      {"L\\MZZQ[JRO",kf_ScreenDump},  //screendump
46
49
 
 
50
        {"noassert", kf_NoAssert}, // turn off asserts
47
51
        {"count me", kf_ShowNumObjects}, // give a count of objects in the world
48
52
        {"give all", kf_AllAvailable},  // give all
49
53
        {"research all", kf_FinishAllResearch}, // research everything at once
72
76
        {"tileinfo", kf_TileInfo}, // output debug info about a tile
73
77
        {"showfps", kf_ToggleFPS},      //displays your average FPS
74
78
        {"showsamples", kf_ToggleSamples}, //displays the # of Sound samples in Queue & List
75
 
        {"end of list",NULL}
 
79
        {"showorders", kf_ToggleOrders}, //displays unit order/action state.
76
80
};
77
81
 
78
82
BOOL attemptCheatCode(const char* cheat_name)
79
83
{
80
 
        UDWORD  index;
81
 
 
82
 
        index = 0;
83
 
 
84
 
        while(cheatCodes[index].function!=NULL)
 
84
        const CHEAT_ENTRY * curCheat;
 
85
        static const CHEAT_ENTRY * const EndCheat = &cheatCodes[ARRAY_SIZE(cheatCodes)];
 
86
 
 
87
        for (curCheat = cheatCodes; curCheat != EndCheat; ++curCheat)
85
88
        {
86
 
                if (strcmp(cheat_name, cheatCodes[index].pName) == 0)
 
89
                if (strcmp(cheat_name, curCheat->pName) == 0)
87
90
                {
 
91
                        char buf[256];
 
92
 
88
93
                        /* We've got our man... */
89
 
                        cheatCodes[index].function();   // run it
 
94
                        curCheat->function();   // run it
 
95
 
 
96
                        // Copy this info to be used by the crash handler for the dump file
 
97
                        ssprintf(buf, "User has used cheat code: %s", curCheat->pName);
 
98
                        addDumpInfo(buf);
 
99
 
90
100
                        /* And get out of here */
91
 
                        return(true);
 
101
                        Cheated = true;
 
102
                        return true;
92
103
                }
93
 
                index++;
94
104
        }
 
105
 
95
106
        /* We didn't find it. Report only for single player games. */
96
107
        if (!runningMultiplayer())
97
108
        {
102
113
 
103
114
                addConsoleMessage(errorString, LEFT_JUSTIFY,SYSTEM_MESSAGE);
104
115
        }
105
 
        return(false);
 
116
 
 
117
        return false;
106
118
}