User Tools

Site Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
general:developer_faq [2012-01-23 11:20]
Carsten [How do I start a new game (MOD) project?]
general:developer_faq [2017-02-06 11:43] (current)
Carsten [How can I clone the Cafu source code repository?]
Line 18: Line 18:
  
 Not only will you become familiar with the Cafu details, you will also be able to form a very competent opinion about Cafu's suitability for your project. Not only will you become familiar with the Cafu details, you will also be able to form a very competent opinion about Cafu's suitability for your project.
 +
 +
 +===== Where are the Visual Studio project files? =====
 +
 +In the development of Cafu, an important consideration is the build process that turns the source code into executable programs.
 +This build process is a challenge in its own right, because it must work
 +  * on all supported platforms (currently Windows and Linux, soon MacOS, too),
 +  * with several compilers (and several versions of each),
 +  * in several variants (32- and 64-bit; debug, profile and release),
 +  * possibly with multiple combinations of the above, simultaneously on the same computer,
 +  * with all external libraries,
 +  * in changing environments (e.g. variable number of game libraries),
 +  * flexibly, robustly and easily configurable for our fellow developers and users.
 +
 +Achieving these goals with Visual Studio solution files on Windows (and possibly Makefiles on Linux) is a maintenance nightmare that borders on the impossible. For these reasons, we have chosen to use [[http://​www.scons.org/​|SCons]] as the build system for the Cafu Engine. SCons meets the above requirements,​ and it can still be used automatically and conveniently from most [[cppdev:​ides]].
 +
 +Alas, we realize that having true Visual Studio project and solution files (and similar native files for other IDEs) would still be nice to have. We therefore started looking into these programs:
 +  * [[http://​industriousone.com/​premake|Premake]]
 +  * [[https://​github.com/​vslavik/​bakefile|Bakefile]]
 +  * [[http://​www.cmake.org|CMake]]
 +These all look very promising, but each has problems of its own, and until today nobody ever finished a complete, working solution. If you would like to help improving the situation, it would be very welcome. Until then, please use one of the solutions described in [[cppdev:​ides]].
  
  
Line 31: Line 52:
  
  
-===== How do locally ​clone the Cafu source code repository? =====+===== How can I clone the Cafu source code repository? =====
  
-When you start working with Cafu, picking up the source code from a compressed archive or from the Subversion ​repository is sometimes not enough:+/* We have recently completed our migration ​from Subversion ​to Git (detailed report: [[http://​forum.cafu.de/​viewtopic.php?​f=14&​t=1090|Part 1]], [[http://​forum.cafu.de/​viewtopic.php?​f=14&​t=1092|Part 2]]). */
  
-Many developers prefer to manage their project in their own, local version-control system, but also wish to integrate the latest changes (e.g. bug-fixes or new features) from the official Cafu repository into theirs from time to time. This synchronization of the projects code with the original ​Cafu source code should be as convenient and automatic as possible. +You can /*now*/ clone the Cafu source code repository like this: 
- +<code bash> 
-One way to achieve ​this is to use Git+> git clone --recursive https://bitbucket.org/cafu/cafu.git Cafu 
-  * http://​stackoverflow.com/​questions/​796991/​fork-and-sync-google-code-svn-into-github +</code>
-  * http://jpz-log.info/archives/2010/​08/​04/​howto-fork-a-subversion-project-with-git/ +
-  * http://​git-scm.com/​ -http://​git-scm.com/​course/​svn.html +
- +
-(TODO: Provide Cafu-specific instructions.)+
  
 +Also see [[cppdev:​gettingstarted]] for more details and https://​bitbucket.org/​cafu/​cafu,​ where you can browse the repository online, create forks, submit pull requests, and find additional help texts.
  
 ===== How do I start a new game (MOD) project? ===== ===== How do I start a new game (MOD) project? =====
  
-/* Text originally contributed as a separate page by Haimi at [[mapping:creatinggamefromdeathmatchfork]]. Moved into the FAQ by Carsten. */+This is now explained in its own section in the documentation:​ 
 +See [[cppdev:startnewgame]] for details.
  
-The key idea is to change into the ''​Games/''​ directory and to create a duplicate of the ''​DeathMatch/''​ directory there. 
-Name the duplicated directory by the name of your game, e.g. ''​MyNewGame/'',​ 
-and rename ''​Games/​MyNewGame/​Code/​DeathMatch.cpp''​ to ''​Games/​MyNewGame/​Code/​MyNewGame.cpp''​. 
  
-Starting a new game as a clone of "​DeathMatch"​ is useful because it gives you immediately ​the proper directory structure, working code, and example files.+===== How do I dynamically reload ​the map script in-game? =====
  
-  * When you then re-run ''​scons''​ as documented at [[cppdev:​gettingstarted]],​ the code of your new game will automatically be picked up, compiled and linked. +While you're developing a script for one of your maps, it can be a very helpful shortcut to reload the map script while the game is runningwithout interrupting ​it. This avoids ​the normally required cycle of leaving and re-starting ​the map.
-  * When you start CaWE, it will automatically recognize ​the new game and show it in the "​Configure",​ "New Map", "New GUI", ... etc. dialogs. If "Start Engine" ​is checked in the "​Compile"​ menu, it will also start the Cafu Engine with the new game. +
-  * If you run the Cafu engine from the command prompt instead, make sure to add parameter <​code>​-svGame MyNewGame</​code>​ +
-  * Also see [[cppdev:​gamecodeoverview]] for details about the game directory.+
  
-You may wish to update all internal paths that still point into the "​DeathMatch"​ directory from ''​Games/​DeathMatch/''​ to ''​Games/​MyNewGame/''​. Under Linuxyou can do it automatically ​like this: +As a preparatory stepadd a function ​like this to your map script
-<​code ​bash+<​code ​lua
-$ find Games/​GameName ​-type f -exec sed -i 's/​DeathMatch/​GameName/g' {} \;+-- This function reloads and runs this script again. 
 +-- It is useful for working with and testing the script "​online",​ 
 +-- i.e. while the game is running and without reloading the map! 
 +function reloadScript() 
 +    -- Adjust the path in the next line as required! 
 +    dofile("​Games/​DeathMatch/​Worlds/BPWxBeta.lua"​);​ 
 +    Console.Print("​Reloaded the map script.\n"); 
 +end
 </​code>​ </​code>​
 +Then, at the [[usermanual:​running#​the_command_console|Cafu in-game console]], enter
 +<code lua>
 +runMapCmd('​reloadScript()'​)
 +</​code>​
 +to dynamically reload the script.
 +
 +In theory, you could combine these two steps into one, using something like ''​runMapCmd('​dofile("​..."​)'​)'',​ but that is even harder to type than the version above, and less flexible. (We realize that the entire ''​runMapCmd(...)''​ business is not optimal. Suggestions for making this more convenient are welcome.)
 +
 +Note that if you use this technique, it can be helpful (but is not required) to understand how it works: The map script "​lives"​ inside a Lua state that is initialized together with the map. (The in-game console has an entirely separate Lua state, which is why ''​runMapCmd(...)''​ is needed.) The above commands essentially run ''​dofile(...)''​ in the context of the maps Lua state, which in turn re-runs the map script.
  
  
general/developer_faq.1327314027.txt.gz · Last modified: 2013-01-07 12:07 (external edit)