List of commits:
Subject Hash Author Date (UTC)
Update en_to_zh, start implementing moddable FileOpen, fix -Wsign-compare 89d00440e1c35d46851fb1d300107da9725d261d mse 2021-05-27 21:29:27
Add a third procedural basket and winnerberry translation string 9b970d581d5094fd3ea7b9da2b4e397c4f4c94db mse 2021-05-27 09:29:02
Add STOPSOUNDS command 22507196106fcd8db7b4bae15b6a2bf9168dd61e mse 2021-05-27 05:56:57
Wake player when hit b2bc7d9cb37a9c9a707e9b8428e6f4d3fa2f27b7 mse 2021-05-26 08:50:53
Minor clarifications d5a83695acdf78b21610239d530b1317dc4003cc mse 2021-05-24 00:11:59
DRM-free dynamic target c51ae66a80c38d4d8aec606ad04492ea12a56fcd mse 2021-05-23 23:53:32
Initial commit bfb7298e48367d2ac0924811b4950f3066ff075c mse 2021-05-22 05:08:16
Commit 89d00440e1c35d46851fb1d300107da9725d261d - Update en_to_zh, start implementing moddable FileOpen, fix -Wsign-compare
Author: mse
Author date (UTC): 2021-05-27 21:29
Committer name: mse
Committer date (UTC): 2021-05-27 21:29
Parent(s): 9b970d581d5094fd3ea7b9da2b4e397c4f4c94db
Signing key:
Tree: fc1b61b5df7662f524ac8c5e9e518bd5c60fe194
File Lines added Lines deleted
confec.cpp 31 24
include/en_to_zh.h 1 0
include/fworld.h 9 4
File confec.cpp changed (mode: 100644) (index af0fc0b..666321a)
1 #include <stdio.h>
2 // fopen override declaration.
3 FILE *FileOpen( const char* filename, const char* modes );
4
1 5 #include <cstring> #include <cstring>
2 6
3 7 // Trick cute_sound.h into thinking stb_vorbis.c is included here. // Trick cute_sound.h into thinking stb_vorbis.c is included here.
 
86 90 #include <en_to_zh.h> #include <en_to_zh.h>
87 91 #include <dialogue.h> #include <dialogue.h>
88 92 #include <fseq.h> #include <fseq.h>
93 #define FWORLD_FOPEN FileOpen
89 94 #include <fworld.h> #include <fworld.h>
90 95
91 96 // Headers specific to Confectioner Engine. // Headers specific to Confectioner Engine.
 
101 106 #include <sys/stat.h> #include <sys/stat.h>
102 107 #endif #endif
103 108
104 #include <stdio.h>
105
106 109 #include <cmath> #include <cmath>
107 110 #include <cstdint> #include <cstdint>
108 111 #include <cstdlib> #include <cstdlib>
 
... ... double ease( double a, double b, double f ){
133 136 } }
134 137
135 138 fgl::Texture loadImage( std::string fileName, bool mipmap, bool filter ){ fgl::Texture loadImage( std::string fileName, bool mipmap, bool filter ){
136 int imgWidth, imgHeight, imgChannels;
137 unsigned char *imgData = stbi_load( fileName.c_str(), &imgWidth, &imgHeight, &imgChannels, 0 );
139 int imgWidth = 0, imgHeight = 0, imgChannels = 0;
140 unsigned char *imgData = nullptr;
141 FILE *file = FileOpen( fileName.c_str(), "rb" );
142 if( file ){
143 imgData = stbi_load_from_file( file, &imgWidth, &imgHeight, &imgChannels, 0 );
144 fclose( file );
145 }
138 146 fgl::Texture imgTexture = fgl::loadTexture( imgData, imgWidth, imgHeight, imgChannels, mipmap, filter ); fgl::Texture imgTexture = fgl::loadTexture( imgData, imgWidth, imgHeight, imgChannels, mipmap, filter );
139 147 stbi_image_free( imgData ); stbi_image_free( imgData );
140 148 return imgTexture; return imgTexture;
 
... ... struct SpecialItem {
405 413 int32_t special_item_result = 0; int32_t special_item_result = 0;
406 414
407 415 // App variable definitions. // App variable definitions.
408 std::string app_version = "v0.4.2";
416 std::string app_version = "v0.4.3";
409 417 #ifdef __DEMO__ #ifdef __DEMO__
410 418 app_version += " demo"; app_version += " demo";
411 419 std::string app_name = "Confectioner Engine Demo"; std::string app_name = "Confectioner Engine Demo";
 
... ... void UpdateInventoryService();
773 781
774 782 void ModUpload( std::string title ); void ModUpload( std::string title );
775 783
776 FILE *FileOpen( const char* filename, const char* modes );
777
778 784 void Render(); void Render();
779 785
780 786 void MakeGibs( double x, double y, linalg::vec<double,3> vel, int n ); void MakeGibs( double x, double y, linalg::vec<double,3> vel, int n );
 
... ... int main( int argc, char* argv[] ){
1040 1046
1041 1047 // Set up graphical effects. // Set up graphical effects.
1042 1048 std::string frag_path = data_path + "/glsl/postfx.frag"; std::string frag_path = data_path + "/glsl/postfx.frag";
1043 FILE* file = fopen( frag_path.c_str(), "rb" );
1049 FILE* file = FileOpen( frag_path.c_str(), "rb" );
1044 1050 if( !file ){ if( !file ){
1045 1051 fprintf( stderr, "Failed to open %s\n", frag_path.c_str() ); fprintf( stderr, "Failed to open %s\n", frag_path.c_str() );
1046 1052 return 1; return 1;
 
... ... int main( int argc, char* argv[] ){
1328 1334 return 0; return 0;
1329 1335 } }
1330 1336
1337 // fopen replacement that attempts to open the file from multiple locations.
1338 FILE *FileOpen( const char* filename, const char* modes ){
1339 // Check if filename starts with the base data path.
1340 std::string str_file = filename, str_data = data_path + "/";
1341 if( str_file.length() >= str_data.length()
1342 && str_file.substr( 0, str_data.length() ) == str_data ){
1343 // TODO: String replacement and iterate through mod paths.
1344 }
1345 // Fall back to open the path specified.
1346 return fopen( filename, modes );
1347 }
1348
1331 1349 #ifdef __EMSCRIPTEN__ #ifdef __EMSCRIPTEN__
1332 1350
1333 1351 void wsConnect( const std::string &uri, void (*f)(std::string) ){ void wsConnect( const std::string &uri, void (*f)(std::string) ){
 
... ... void HitCallback( fworld::Entity *ent_a, fworld::Entity *ent_b, int damage ){
2451 2469 // Wake the entity. // Wake the entity.
2452 2470 ent_b->task = fworld::TASK_NONE; ent_b->task = fworld::TASK_NONE;
2453 2471 ent_b->stun = 0.0; ent_b->stun = 0.0;
2454 if( world.followEntity >= 0 && world.followEntity < world.entities.size()
2472 if( world.followEntity >= 0
2473 && world.entities.size() > (size_t)world.followEntity
2455 2474 && ent_b == &world.entities[world.followEntity] ){ && ent_b == &world.entities[world.followEntity] ){
2456 2475 // The player is hit, so turn off sleep mode. // The player is hit, so turn off sleep mode.
2457 2476 sleep_mode = false; sleep_mode = false;
 
... ... void SoundSpecLoad( std::string sounds_path, std::string spec_path ){
2712 2731 cs_stop_all_sounds( csctx ); cs_stop_all_sounds( csctx );
2713 2732
2714 2733 // Load the spec file. // Load the spec file.
2715 FILE* file = fopen( spec_path.c_str(), "rb" );
2734 FILE* file = FileOpen( spec_path.c_str(), "rb" );
2716 2735 if( !file ){ if( !file ){
2717 2736 fprintf( stderr, "Failed to open %s\n", spec_path.c_str() ); fprintf( stderr, "Failed to open %s\n", spec_path.c_str() );
2718 2737 return; return;
 
... ... void LoadMap( std::string file_path, bool autosave ){
3184 3203 // Return the entity that will be spawned when the specified map is loaded. // Return the entity that will be spawned when the specified map is loaded.
3185 3204 fworld::Entity GetMapSpawn( std::string dataPath, std::string filePath ){ fworld::Entity GetMapSpawn( std::string dataPath, std::string filePath ){
3186 3205 // Load the map JSON file. // Load the map JSON file.
3187 FILE* file = fopen( filePath.c_str(), "rb" );
3206 FILE* file = FileOpen( filePath.c_str(), "rb" );
3188 3207 if( !file ) return {}; if( !file ) return {};
3189 3208 std::string text = ""; std::string text = "";
3190 3209 char buf[4096]; char buf[4096];
 
... ... void ModUpload( std::string title ){
4084 4103 #endif #endif
4085 4104 } }
4086 4105
4087 // fopen replacement that attempts to open the file from multiple locations.
4088 FILE *FileOpen( const char* filename, const char* modes ){
4089 // Check if filename starts with the base data path.
4090 std::string str_file = filename, str_data = data_path + "/";
4091 if( str_file.length() >= str_data.length()
4092 && str_file.substr( 0, str_data.length() ) == str_data ){
4093 // TODO: String replacement and iterate through mod paths.
4094 }
4095 // Fall back to open the path specified.
4096 return fopen( filename, modes );
4097 }
4098
4099 4106 void Render(){ void Render(){
4100 4107 double d = fgl::deltaTime(); double d = fgl::deltaTime();
4101 4108
 
... ... void DrawSpecialItems(
5235 5242 // in the current language. // in the current language.
5236 5243 std::string dialogue_name = std::string dialogue_name =
5237 5244 std::to_string( item.id ) + ".json"; std::to_string( item.id ) + ".json";
5238 FILE *file = fopen(
5245 FILE *file = FileOpen(
5239 5246 ( data_path + "/dialogue_" + language + "/" + dialogue_name ).c_str(), ( data_path + "/dialogue_" + language + "/" + dialogue_name ).c_str(),
5240 5247 "rb" "rb"
5241 5248 ); );
File include/en_to_zh.h changed (mode: 100644) (index 0cfb5f4..39aa26f)
... ... const std::map<std::string,std::string> translate_en_zh = {
256 256 { "new", "新" }, { "new", "新" },
257 257 { "formula", "配方" }, { "formula", "配方" },
258 258 { "recipe", "配方" }, { "recipe", "配方" },
259 { "winnerberry", "优胜者莓" }, // Not a word, I know.
259 260 { "one", "一" }, { "one", "一" },
260 261 { "two", "两个" }, { "two", "两个" },
261 262 { "three", "三个" }, { "three", "三个" },
File include/fworld.h changed (mode: 100755) (index fdcd15a..ede7752)
28 28 #define fgl fg4 #define fgl fg4
29 29 #endif #endif
30 30
31 // Moddable fopen.
32 #ifndef FWORLD_FOPEN
33 #define FWORLD_FOPEN fopen
34 #endif
35
31 36 namespace fworld { namespace fworld {
32 37
33 38 bool verbose = true; bool verbose = true;
 
... ... void World::loadMap( std::string dataPath, std::string filePath ){
663 668 mapFile = filePath; mapFile = filePath;
664 669
665 670 // Load the map JSON file. // Load the map JSON file.
666 FILE* file = fopen( filePath.c_str(), "rb" );
671 FILE* file = FWORLD_FOPEN( filePath.c_str(), "rb" );
667 672 if( !file ){ if( !file ){
668 673 fprintf( stderr, "Failed to open %s\n", filePath.c_str() ); fprintf( stderr, "Failed to open %s\n", filePath.c_str() );
669 674 return; return;
 
... ... void World::loadMap( std::string dataPath, std::string filePath ){
701 706 std::string tsPath = dataPath + "/" + tilesetDefinition; std::string tsPath = dataPath + "/" + tilesetDefinition;
702 707
703 708 // Load the tileset JSON file. // Load the tileset JSON file.
704 file = fopen( tsPath.c_str(), "rb" );
709 file = FWORLD_FOPEN( tsPath.c_str(), "rb" );
705 710 if( !file ){ if( !file ){
706 711 fprintf( stderr, "Failed to open %s\n", tsPath.c_str() ); fprintf( stderr, "Failed to open %s\n", tsPath.c_str() );
707 712 jsonFreeDocument( &allocatedDocument ); jsonFreeDocument( &allocatedDocument );
 
... ... void World::unloadMap(){
869 874
870 875 void World::loadItems( std::string filePath ){ void World::loadItems( std::string filePath ){
871 876 // Load the item table JSON file. // Load the item table JSON file.
872 FILE* file = fopen( filePath.c_str(), "rb" );
877 FILE* file = FWORLD_FOPEN( filePath.c_str(), "rb" );
873 878 if( !file ){ if( !file ){
874 879 fprintf( stderr, "Failed to open %s\n", filePath.c_str() ); fprintf( stderr, "Failed to open %s\n", filePath.c_str() );
875 880 return; return;
 
... ... void World::saveMap( std::string filePath ){
1417 1422 result += "]\n}\n]\n}\n"; result += "]\n}\n]\n}\n";
1418 1423
1419 1424 // Save the map JSON file. // Save the map JSON file.
1420 FILE* file = fopen( filePath.c_str(), "wb" );
1425 FILE* file = FWORLD_FOPEN( filePath.c_str(), "wb" );
1421 1426 if( file ){ if( file ){
1422 1427 // Treat the file as a regular string for string-like output. // Treat the file as a regular string for string-like output.
1423 1428 fputs( result.c_str(), file ); fputs( result.c_str(), file );
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/mse/ConfectionerEngine

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/mse/ConfectionerEngine

Clone this repository using git:
git clone git://git.rocketgit.com/user/mse/ConfectionerEngine

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main