diff --git a/build-windows/go b/build-windows/go index fa2dd6f0..5956d0bf 100644 --- a/build-windows/go +++ b/build-windows/go @@ -78,7 +78,7 @@ if [ "$release" -eq "1" ]; then exit fi -($skipmake || $makecmd CFLAGS="$DEBUGFLAGS_CC" CXXFLAGS="$DEBUGFLAGS_CXX") && +($skipmake || $makecmd CFLAGS="$DEBUGFLAGS_CC" CXXFLAGS="$DEBUGFLAGS_CXX" -j9 ) && if [ "$run" -eq "1" ]; then if [ "$debug" -eq "2" ]; then drmemory -logdir ./drmemory -- principia diff --git a/src/src/game-gui.cc b/src/src/game-gui.cc index ebea0ca0..aae49aee 100644 --- a/src/src/game-gui.cc +++ b/src/src/game-gui.cc @@ -1444,7 +1444,7 @@ game::widget_clicked(principia_wdg *w, uint8_t button_id, int pid) P.add_action(ACTION_AUTOSAVE, 0); P.num_unread_messages = 0; char tmp[256]; - snprintf(tmp, 255, "http://" COMMUNITY_HOST "/user/%s", P.username); + snprintf(tmp, 255, "http://%s/user/%s", P.community_host, P.username); ui::open_url(tmp); snprintf(tmp, 255, "%s", P.username); diff --git a/src/src/main.cc b/src/src/main.cc index b4bb7afe..c0cfce18 100644 --- a/src/src/main.cc +++ b/src/src/main.cc @@ -1970,7 +1970,8 @@ _download_pkg(void *_p) tms_debugf("save: %s", save_path); char url[1024]; - sprintf(url, "http://" COMMUNITY_HOST "/" COMMUNITY_SECRET "/xxxx.php?i=%d", + snprintf(url, 1023, "http://%s/" COMMUNITY_SECRET "/xxxx.php?i=%d", + P.community_host, _play_pkg_id); //tms_infof("url: %s", url); long http_code = 0; @@ -2110,7 +2111,8 @@ _download_level(void *p) char url[1024]; - sprintf(url, "http://" COMMUNITY_HOST "/" COMMUNITY_SECRET "/%s.php?i=%d&h=%u", + snprintf(url, 1023, "http://%s/" COMMUNITY_SECRET "/%s.php?i=%d&h=%u", + P.community_host, _play_download_for_pkg ? "xxxxx" : (type == LEVEL_DB ? "x":(derive == true ? "xxx" : "xxxxxx")), _play_id, r); //tms_infof("url: %s", url); @@ -2522,7 +2524,9 @@ _check_version_code(void *_unused) if (P.curl) { init_curl_defaults(P.curl); - curl_easy_setopt(P.curl, CURLOPT_URL, "http://" COMMUNITY_HOST "/principia-version-code"); + char url[1024]; + snprintf(url, 1023, "http://%s/principia-version-code", P.community_host); + curl_easy_setopt(P.curl, CURLOPT_URL, url); curl_easy_setopt(P.curl, CURLOPT_WRITEFUNCTION, write_memory_cb); curl_easy_setopt(P.curl, CURLOPT_WRITEDATA, (void*)&chunk); @@ -2547,7 +2551,7 @@ _check_version_code(void *_unused) #elif defined TMS_BACKEND_IOS ui::message("A new version of Principia is available. Please visit the App Store to get the latest version.", true); # else - ui::message("A new version of Principia is available. Please go to " COMMUNITY_HOST " to download the latest version.", true); + ui::message("A new version of Principia is available. Please go to www.principiagame.com/download to download the latest version.", true); # endif } @@ -2625,9 +2629,9 @@ _get_featured_levels(void *_num) char url[1024]; if (fl_fetch_time && file_exists(featured_data_path) && !ignore_fl_cache) { - snprintf(url, 1023, "http://" COMMUNITY_HOST "/" COMMUNITY_SECRET "/get_feature.php?num=%" PRIu32 "&time=%d", num_featured_levels, fl_fetch_time); + snprintf(url, 1023, "http://%s/" COMMUNITY_SECRET "/get_feature.php?num=%" PRIu32 "&time=%d", P.community_host, num_featured_levels, fl_fetch_time); } else { - snprintf(url, 1023, "http://" COMMUNITY_HOST "/" COMMUNITY_SECRET "/get_feature.php?num=%" PRIu32, num_featured_levels); + snprintf(url, 1023, "http://%s/" COMMUNITY_SECRET "/get_feature.php?num=%" PRIu32, P.community_host, num_featured_levels); } curl_easy_setopt(P.curl, CURLOPT_URL, url); @@ -2968,7 +2972,9 @@ _publish_pkg(void *_unused) if (P.curl) { init_curl_defaults(P.curl); - curl_easy_setopt(P.curl, CURLOPT_URL, "http://" COMMUNITY_HOST "/" COMMUNITY_SECRET "/upload_package.php"); + char url[1024]; + snprintf(url, 1023, "http://%s/" COMMUNITY_SECRET "/upload_package.php", P.community_host); + curl_easy_setopt(P.curl, CURLOPT_URL, url); curl_easy_setopt(P.curl, CURLOPT_HTTPPOST, formpost); @@ -3110,7 +3116,9 @@ _publish_level(void *p) if (P.curl) { init_curl_defaults(P.curl); - curl_easy_setopt(P.curl, CURLOPT_URL, "http://" COMMUNITY_HOST "/upload.php"); + char url[1024]; + snprintf(url, 1023, "http://%s/upload.php", P.community_host); + curl_easy_setopt(P.curl, CURLOPT_URL, url); curl_easy_setopt(P.curl, CURLOPT_HTTPPOST, formpost); @@ -3300,7 +3308,9 @@ _submit_score(void *p) struct header_data hd = {0}; init_curl_defaults(P.curl); - curl_easy_setopt(P.curl, CURLOPT_URL, "http://" COMMUNITY_HOST "/" COMMUNITY_SECRET "/submit_score.php"); + char url[1024]; + snprintf(url, 1023, "http://%s/" COMMUNITY_SECRET "/submit_score.php", P.community_host); + curl_easy_setopt(P.curl, CURLOPT_URL, url); curl_easy_setopt(P.curl, CURLOPT_WRITEHEADER, &hd); @@ -3383,7 +3393,9 @@ _ping(void *p) if (P.curl) { init_curl_defaults(P.curl); - curl_easy_setopt(P.curl, CURLOPT_URL, "http://" COMMUNITY_HOST "/ping.php"); + char url[1024]; + snprintf(url, 1023, "http://%s/ping.php", P.community_host); + curl_easy_setopt(P.curl, CURLOPT_URL, url); curl_easy_setopt(P.curl, CURLOPT_WRITEFUNCTION, write_memory_cb); curl_easy_setopt(P.curl, CURLOPT_WRITEDATA, (void*)&chunk); @@ -3457,7 +3469,9 @@ _login(void *p) if (P.curl) { init_curl_defaults(P.curl); - curl_easy_setopt(P.curl, CURLOPT_URL, "http://" COMMUNITY_HOST "/" COMMUNITY_SECRET "/xx.php"); + char url[1024]; + snprintf(url, 1023, "http://%s/" COMMUNITY_SECRET "/xx.php", P.community_host); + curl_easy_setopt(P.curl, CURLOPT_URL, url); curl_easy_setopt(P.curl, CURLOPT_HTTPPOST, formpost); @@ -3573,8 +3587,9 @@ _register(void *p) if (P.curl) { init_curl_defaults(P.curl); - - curl_easy_setopt(P.curl, CURLOPT_URL, "http://" COMMUNITY_HOST "/" COMMUNITY_SECRET "/" REGISTER_ANDROID_FILE ".php"); + char url[1024]; + snprintf(url, 1023, "http://%s/" COMMUNITY_SECRET "/" REGISTER_ANDROID_FILE ".php", P.community_host); + curl_easy_setopt(P.curl, CURLOPT_URL, url); curl_easy_setopt(P.curl, CURLOPT_HTTPPOST, formpost); @@ -3711,7 +3726,9 @@ _link_account(void *p) if (P.curl) { init_curl_defaults(P.curl); - curl_easy_setopt(P.curl, CURLOPT_URL, "http://" COMMUNITY_HOST "/" COMMUNITY_SECRET "/" LINK_ACCOUNT_FILE ".php"); + char url[1024]; + snprintf(url, 1023, "http://%s/" COMMUNITY_SECRET "/" LINK_ACCOUNT_FILE ".php", P.community_host); + curl_easy_setopt(P.curl, CURLOPT_URL, url); curl_easy_setopt(P.curl, CURLOPT_HTTPPOST, formpost); @@ -4039,6 +4056,7 @@ initial_loader(int step) switch (step) { case 0: { + P.community_host = "principia-web.se"; static const char *u_dirs[]={ "/lvl", "/lvl/local", "/pkg", "/pkg/local", @@ -4381,7 +4399,9 @@ P_get_cookie_data(char **u, char **k, char **sid, char **l) if (P.curl) { init_curl_defaults(P.curl); - curl_easy_setopt(P.curl, CURLOPT_URL, "http://" COMMUNITY_HOST "/" COMMUNITY_SECRET "/xx.php"); + char url[1024]; + snprintf(url, 1023, "http://%s/" COMMUNITY_SECRET "/xx.php", P.community_host); + curl_easy_setopt(P.curl, CURLOPT_URL, url); struct curl_slist *cookies; CURLcode res = curl_easy_getinfo(P.curl, CURLINFO_COOKIELIST, &cookies); diff --git a/src/src/main.hh b/src/src/main.hh index 6b995e30..fa7f2f50 100644 --- a/src/src/main.hh +++ b/src/src/main.hh @@ -25,28 +25,15 @@ class pkginfo; #define STR1(x) #x #define STR(x) STR1(x) -#if defined(DEBUG) -# ifdef PAJLADA -//# define COMMUNITY_HOST "pajlada.se" -# define COMMUNITY_HOST "principiagame.com" -# else -# define COMMUNITY_HOST "principiagame.com" -# endif -#else -# define COMMUNITY_HOST "principiagame.com" -#endif +#define UPDATE_URL "http://www.principiagame.com/download" #if defined(TMS_BACKEND_WINDOWS) #define OS_STRING "Windows" -#define UPDATE_URL "http://" COMMUNITY_HOST "/download" #elif defined(TMS_BACKEND_LINUX_SS) #define OS_STRING "Linux_SS" -#define UPDATE_URL "http://" COMMUNITY_HOST "/download" #elif defined(TMS_BACKEND_LINUX) #define OS_STRING "Linux" -#define UPDATE_URL "http://" COMMUNITY_HOST "/download" #elif defined(TMS_BACKEND_ANDROID) -#define UPDATE_URL "http://play.google.com/store/apps/details?id=com.bithack.principia" # if defined(TMS_BACKEND_ANDROID_X86) # define OS_STRING "Android x86" # elif defined(TMS_BACKEND_ANDROID_ARMEABI) @@ -57,11 +44,9 @@ class pkginfo; # define OS_STRING "Android" # endif #elif defined(TMS_BACKEND_IOS) -#define UPDATE_URL "http://" COMMUNITY_HOST "/download?appstore" #define OS_STRING "iOS" #else #define OS_STRING "unknown" -#define UPDATE_URL "http://" COMMUNITY_HOST "/download" #endif #if defined(TMS_BACKEND_ANDROID) || defined(TMS_BACKEND_IOS) @@ -280,6 +265,7 @@ extern class principia int focused; bool loaded; + const char *community_host; char *username; int user_id; int num_unread_messages; diff --git a/src/src/menu-base.cc b/src/src/menu-base.cc index 924e5821..e4911d0d 100644 --- a/src/src/menu-base.cc +++ b/src/src/menu-base.cc @@ -32,8 +32,8 @@ menu_base::widget_clicked(principia_wdg *w, uint8_t button_id, int pid) pscreen::refresh_username(); P.add_action(ACTION_REFRESH_WIDGETS, 0); - char tmp[256]; - snprintf(tmp, 255, "http://" COMMUNITY_HOST "/user/%s", P.username); + char tmp[1024]; + snprintf(tmp, 1023, "http://%s/user/%s", P.community_host, P.username); ui::open_url(tmp); } else { ui::open_dialog(DIALOG_LOGIN); @@ -42,7 +42,11 @@ menu_base::widget_clicked(principia_wdg *w, uint8_t button_id, int pid) break; case BTN_MESSAGE: - ui::open_url("http://" COMMUNITY_HOST "/version-redir.php"); + { + char url[1024]; + snprintf(url, 1023, "http://%s/version-redir.php", P.community_host); + ui::open_url(url); + } break; case BTN_BITHACK: @@ -56,8 +60,8 @@ menu_base::widget_clicked(principia_wdg *w, uint8_t button_id, int pid) case BTN_ENTITY: { uint32_t id = VOID_TO_UINT32(w->data3); - char tmp[512]; - snprintf(tmp, 511, "http://" COMMUNITY_HOST "/level/%" PRIu32, id); + char tmp[1024]; + snprintf(tmp, 1023, "http://%s/level/%" PRIu32, P.community_host, id); ui::open_url(tmp); } break; @@ -65,8 +69,8 @@ menu_base::widget_clicked(principia_wdg *w, uint8_t button_id, int pid) case BTN_CONTEST: { uint32_t id = VOID_TO_UINT32(w->data3); - char tmp[512]; - snprintf(tmp, 511, "http://" COMMUNITY_HOST "/contest/%" PRIu32, id); + char tmp[1024]; + snprintf(tmp, 1023, "http://%s/contest/%" PRIu32, P.community_host, id); ui::open_url(tmp); } break; diff --git a/src/src/menu_main.cc b/src/src/menu_main.cc index be1c6309..7987ce18 100644 --- a/src/src/menu_main.cc +++ b/src/src/menu_main.cc @@ -25,7 +25,7 @@ menu_main::widget_clicked(principia_wdg *w, uint8_t button_id, int pid) switch (button_id) { case BTN_SHITTY: { - ui::open_url("http://wiki." COMMUNITY_HOST "/wiki/Bad_Graphics"); + ui::open_url("http://wiki.principiagame.com/wiki/Bad_Graphics"); } break; @@ -56,7 +56,7 @@ menu_main::widget_clicked(principia_wdg *w, uint8_t button_id, int pid) ui::open_url(0); #else char tmp[512]; - sprintf(tmp, "http://%s/", COMMUNITY_HOST); + snprintf(tmp, 511, "http://%s/", P.community_host); ui::open_url(tmp); #endif } @@ -226,7 +226,7 @@ menu_main::handle_input(tms::event *ev, int action) return T_OK; case TMS_KEY_V: - tms_debugf("Community host: %s. Update URL: %s", COMMUNITY_HOST, UPDATE_URL); + tms_debugf("Community host: %s. Update URL: %s", P.community_host, UPDATE_URL); return T_OK; case TMS_KEY_O: diff --git a/src/src/ui.cc b/src/src/ui.cc index a0e1acae..97fc81c9 100644 --- a/src/src/ui.cc +++ b/src/src/ui.cc @@ -583,7 +583,7 @@ void ui_cb_back_to_community(void) { char tmp[1024]; - snprintf(tmp, 1023, "http://" COMMUNITY_HOST "/level/%d", W->level.community_id); + snprintf(tmp, 1023, "http://%s/level/%d", P.community_host, W->level.community_id); ui::open_url(tmp); } @@ -936,7 +936,7 @@ extern "C" jstring Java_org_libsdl_app_PrincipiaBackend_getLevelPage(JNIEnv *env, jclass jcls) { char tmp[1024]; - snprintf(tmp, 1023, "http://" COMMUNITY_HOST "/level/%d", W->level.community_id); + snprintf(tmp, 1023, "http://%s/level/%d", P.community_host, W->level.community_id); return env->NewStringUTF(tmp); } @@ -1770,8 +1770,8 @@ Java_org_libsdl_app_PrincipiaBackend_setConsumableType(JNIEnv *env, jclass _jcls extern "C" jstring Java_org_libsdl_app_PrincipiaBackend_getCurrentCommunityUrl(JNIEnv *env, jclass _jcls) { - char tmp[256]; - snprintf(tmp, 255, "http://" COMMUNITY_HOST "/level/%d", W->level.community_id); + char tmp[1024]; + snprintf(tmp, 1023, "http://%s/level/%d", P.community_host, W->level.community_id); return env->NewStringUTF(tmp); } @@ -9105,7 +9105,9 @@ on_login_btn_click(GtkWidget *w, GdkEventButton *ev, gpointer user_data) gtk_label_set_text(login_status, "Enter data into both fields."); } } else if (btn_pressed(w, login_btn_forgot_password, user_data)) { - ui::open_url("http://" COMMUNITY_HOST "/forgot_password.php"); + char url[1024]; + snprintf(url, 1023, "http://%s/forgot_password.php", P.community_host); + ui::open_url(url); } return false; @@ -13533,7 +13535,7 @@ _open_tips_dialog(gpointer unused) } if (result == GTK_RESPONSE_YES) - ui::open_url("http://" COMMUNITY_HOST "/gettingstarted.php"); + ui::open_url("http://wiki.principiagame.com/"); break; } while (true); @@ -13738,7 +13740,7 @@ _open_published(gpointer unused) case GTK_RESPONSE_ACCEPT: { char tmp[1024]; - snprintf(tmp, 1023, "http://" COMMUNITY_HOST "/level/%d", W->level.community_id); + snprintf(tmp, 1023, "http://%s/level/%d", P.community_host, W->level.community_id); ui::open_url(tmp); }