forked from Mirrorlandia_minetest/minetest
Refactor the_game() to make it more understandable and maintainable.
The following is a record of 31 commits before squashing: Revert "Remove m_ext_ptr in GUIFormSpecMenu, replaced by refcount mechanism" This reverts commit b49e5cfc7013cef7e9af79d17e04f7e7e4c377d4. Basic reformatting with astyle -- additional formatting will be modified, manually, as the need for it is encountered Start "outlining" what a MinetestApp class might look like Add MinetestApp::shutdown() Converted class member functions to camelCase and created protos for new functions First stage of connect to server done Add get itemdefs/nodedefs/media code Init clouds, camera, sky, init GUI, HUD Input handling Client events, camera, sound, draw Fix wield hand getting stuck digging and add debug text back Fix FPS Added profiler graph back Fix FPS issue Need to work out what went wrong and clean up the copy/paste stuff Annotate Various: Rewrote limitFps() Limited scope of some variables Jitter calcs Reduce scope of objects Move some stuff out of ::run and minor formatting cleanup Scope reduction Function splits Removed old (broken) limitFps() Added exception handling back Fixed some formatting Reverted commented out unit tests (uncommented them) Slow clouds down on loading and media screens so the behaviour is like the original the_game() Formatting/style (no functional changes) Manually reapply upstream b49e5cf: Remove m_ext_ptr in GUIFormSpecMenu, replaced by refcount mechanism Fixed silly errors on my part Minor formatting cleanups Removed strange differentiation in FPS limiting when loading FPS limiting was done differently if cloud_menu_background was true, which does not make sense Cleaning up Add some comments
This commit is contained in:
parent
9e811a92e7
commit
429ecb2b94
3821
src/game.cpp
3821
src/game.cpp
File diff suppressed because it is too large
Load Diff
31
src/game.h
31
src/game.h
@ -35,11 +35,14 @@ class KeyList : protected std::list<KeyPress>
|
|||||||
{
|
{
|
||||||
const_iterator f(begin());
|
const_iterator f(begin());
|
||||||
const_iterator e(end());
|
const_iterator e(end());
|
||||||
|
|
||||||
while (f != e) {
|
while (f != e) {
|
||||||
if (*f == key)
|
if (*f == key)
|
||||||
return f;
|
return f;
|
||||||
|
|
||||||
++f;
|
++f;
|
||||||
}
|
}
|
||||||
|
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,16 +50,22 @@ class KeyList : protected std::list<KeyPress>
|
|||||||
{
|
{
|
||||||
iterator f(begin());
|
iterator f(begin());
|
||||||
iterator e(end());
|
iterator e(end());
|
||||||
|
|
||||||
while (f != e) {
|
while (f != e) {
|
||||||
if (*f == key)
|
if (*f == key)
|
||||||
return f;
|
return f;
|
||||||
|
|
||||||
++f;
|
++f;
|
||||||
}
|
}
|
||||||
|
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void clear() { super::clear(); }
|
void clear()
|
||||||
|
{
|
||||||
|
super::clear();
|
||||||
|
}
|
||||||
|
|
||||||
void set(const KeyPress &key)
|
void set(const KeyPress &key)
|
||||||
{
|
{
|
||||||
@ -67,6 +76,7 @@ public:
|
|||||||
void unset(const KeyPress &key)
|
void unset(const KeyPress &key)
|
||||||
{
|
{
|
||||||
iterator p(find(key));
|
iterator p(find(key));
|
||||||
|
|
||||||
if (p != end())
|
if (p != end())
|
||||||
erase(p);
|
erase(p);
|
||||||
}
|
}
|
||||||
@ -74,6 +84,7 @@ public:
|
|||||||
void toggle(const KeyPress &key)
|
void toggle(const KeyPress &key)
|
||||||
{
|
{
|
||||||
iterator p(this->find(key));
|
iterator p(this->find(key));
|
||||||
|
|
||||||
if (p != end())
|
if (p != end())
|
||||||
erase(p);
|
erase(p);
|
||||||
else
|
else
|
||||||
@ -117,30 +128,28 @@ public:
|
|||||||
|
|
||||||
virtual s32 getMouseWheel() = 0;
|
virtual s32 getMouseWheel() = 0;
|
||||||
|
|
||||||
virtual void step(float dtime) {};
|
virtual void step(float dtime) {}
|
||||||
|
|
||||||
virtual void clear() {};
|
virtual void clear() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class ChatBackend; /* to avoid having to include chat.h */
|
class ChatBackend; /* to avoid having to include chat.h */
|
||||||
struct SubgameSpec;
|
struct SubgameSpec;
|
||||||
|
|
||||||
void the_game(
|
void the_game(bool *kill,
|
||||||
bool &kill,
|
|
||||||
bool random_input,
|
bool random_input,
|
||||||
InputHandler *input,
|
InputHandler *input,
|
||||||
IrrlichtDevice *device,
|
IrrlichtDevice *device,
|
||||||
gui::IGUIFont *font,
|
gui::IGUIFont *font,
|
||||||
std::string map_dir,
|
const std::string &map_dir,
|
||||||
std::string playername,
|
const std::string &playername,
|
||||||
std::string password,
|
const std::string &password,
|
||||||
std::string address, // If "", local server is used
|
const std::string &address, // If "", local server is used
|
||||||
u16 port,
|
u16 port,
|
||||||
std::wstring &error_message,
|
std::wstring &error_message,
|
||||||
ChatBackend &chat_backend,
|
ChatBackend &chat_backend,
|
||||||
const SubgameSpec &gamespec, // Used for local game
|
const SubgameSpec &gamespec, // Used for local game
|
||||||
bool simple_singleplayer_mode
|
bool simple_singleplayer_mode);
|
||||||
);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1861,7 +1861,7 @@ int main(int argc, char *argv[])
|
|||||||
g_touchscreengui = receiver->m_touchscreengui;
|
g_touchscreengui = receiver->m_touchscreengui;
|
||||||
#endif
|
#endif
|
||||||
the_game(
|
the_game(
|
||||||
kill,
|
&kill,
|
||||||
random_input,
|
random_input,
|
||||||
input,
|
input,
|
||||||
device,
|
device,
|
||||||
|
Loading…
Reference in New Issue
Block a user