Removed two local vars that were set and then never used.
[blender.git] / source / gameengine / Ketsji / KX_GameActuator.cpp
1 /**
2 * global game stuff
3 *
4 * $Id$
5 *
6  * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version. The Blender
12  * Foundation also sells licenses for use in proprietary software under
13  * the Blender License.  See http://www.blender.org/BL/ for information
14  * about this.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software Foundation,
23  * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
24  *
25  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
26  * All rights reserved.
27  *
28  * The Original Code is: all of this file.
29  *
30  * Contributor(s): none yet.
31  *
32  * ***** END GPL/BL DUAL LICENSE BLOCK *****
33 */
34
35 #include "SCA_IActuator.h"
36 #include "KX_GameActuator.h"
37 //#include <iostream>
38 #include "KX_Scene.h"
39 #include "KX_KetsjiEngine.h"
40
41 #ifdef HAVE_CONFIG_H
42 #include <config.h>
43 #endif
44
45 /* ------------------------------------------------------------------------- */
46 /* Native functions                                                          */
47 /* ------------------------------------------------------------------------- */
48
49 KX_GameActuator::KX_GameActuator(SCA_IObject *gameobj, 
50                                                                    int mode,
51                                                                    const STR_String& filename,
52                                                                    const STR_String& loadinganimationname,
53                                                                    KX_Scene* scene,
54                                                                    KX_KetsjiEngine* ketsjiengine,
55                                                                    PyTypeObject* T)
56                                                                    : SCA_IActuator(gameobj, T)
57 {
58         m_mode = mode;
59         m_filename = filename;
60         m_loadinganimationname = loadinganimationname;
61         m_scene = scene;
62         m_ketsjiengine = ketsjiengine;
63 } /* End of constructor */
64
65
66
67 KX_GameActuator::~KX_GameActuator()
68
69         // there's nothing to be done here, really....
70 } /* end of destructor */
71
72
73
74 CValue* KX_GameActuator::GetReplica()
75 {
76         KX_GameActuator* replica = new KX_GameActuator(*this);
77         replica->ProcessReplica();
78         // this will copy properties and so on...
79         CValue::AddDataToReplica(replica);
80         
81         return replica;
82 }
83
84
85
86 bool KX_GameActuator::Update(double curtime, double deltatime)
87 {
88         bool bNegativeEvent = IsNegativeEvent();
89         RemoveAllEvents();
90
91         if (bNegativeEvent)
92                 return false; // do nothing on negative events
93
94         switch (m_mode)
95         {
96         case KX_GAME_LOAD:
97         case KX_GAME_START:
98                 {
99                         if (m_ketsjiengine)
100                         {
101                                 STR_String exitstring = "start other game";
102                                 m_ketsjiengine->RequestExit(KX_EXIT_REQUEST_START_OTHER_GAME);
103                                 m_ketsjiengine->SetNameNextGame(m_filename);
104                                 m_scene->AddDebugProperty((this)->GetParent(), exitstring);
105                         }
106
107                         break;
108                 }
109         case KX_GAME_RESTART:
110                 {
111                         if (m_ketsjiengine)
112                         {
113                                 STR_String exitstring = "restarting game";
114                                 m_ketsjiengine->RequestExit(KX_EXIT_REQUEST_RESTART_GAME);
115                                 m_scene->AddDebugProperty((this)->GetParent(), exitstring);
116                         }
117                         break;
118                 }
119         case KX_GAME_QUIT:
120                 {
121                         if (m_ketsjiengine)
122                         {
123                                 STR_String exitstring = "quiting game";
124                                 m_ketsjiengine->RequestExit(KX_EXIT_REQUEST_QUIT_GAME);
125                                 m_scene->AddDebugProperty((this)->GetParent(), exitstring);
126                         }
127                         break;
128                 }
129         default:
130                 ; /* do nothing? this is an internal error !!! */
131         }
132         
133         return false;
134 }
135
136
137
138
139
140 /* ------------------------------------------------------------------------- */
141 /* Python functions                                                          */
142 /* ------------------------------------------------------------------------- */
143
144 /* Integration hooks ------------------------------------------------------- */
145 PyTypeObject KX_GameActuator::Type = {
146         PyObject_HEAD_INIT(&PyType_Type)
147                 0,
148                 "KX_SceneActuator",
149                 sizeof(KX_GameActuator),
150                 0,
151                 PyDestructor,
152                 0,
153                 __getattr,
154                 __setattr,
155                 0, //&MyPyCompare,
156                 __repr,
157                 0, //&cvalue_as_number,
158                 0,
159                 0,
160                 0,
161                 0
162 };
163
164
165
166 PyParentObject KX_GameActuator::Parents[] =
167 {
168         &KX_GameActuator::Type,
169                 &SCA_IActuator::Type,
170                 &SCA_ILogicBrick::Type,
171                 &CValue::Type,
172                 NULL
173 };
174
175
176
177 PyMethodDef KX_GameActuator::Methods[] =
178 {
179         {NULL,NULL} //Sentinel
180 };
181
182
183
184 PyObject* KX_GameActuator::_getattr(char* attr)
185 {
186         _getattr_up(SCA_IActuator);
187 }
188
189