Remove DEMO code

This commit is contained in:
ROllerozxa 2022-08-06 19:51:11 +02:00 committed by ROllerozxa
commit f9aa1b14d1
10 changed files with 14 additions and 355 deletions

View file

@ -75,17 +75,6 @@ enum {
#define IDD_PLAYING_COMMUNITY_LEVEL (1ULL << 3)
#define IDD_IN_MENU (1ULL << 4)
#define LICENSE_LEVEL_ID 3726592
#define LICENSE_CHECK_INTERVAL_MINUTES 10
#define LICENSE_CHECK_INTERVAL \
(1000000*60*LICENSE_CHECK_INTERVAL_MINUTES)
#if defined TMS_BACKEND_LINUX || defined TMS_BACKEND_WINDOWS
#define LICENSE_IS_VALID() (progress::get_level_progress(LEVEL_MAIN, LICENSE_LEVEL_ID)->completed)
#else
#define LICENSE_IS_VALID() true
#endif
#define NUM_LAYERS 3
#define LAYER_DEPTH 1.f

View file

@ -104,7 +104,6 @@ tms_sprite *catsprites[of::num_categories+1];
tms_sprite *catsprite_hints[of::num_categories];
tms_sprite *filterlabel;
tms_sprite *factionlabel;
tms_sprite *demosprite;
static int widest_catsprite = 0;
static int tallest_catsprite = 0;
@ -1594,7 +1593,6 @@ game::init_gui(void)
filterlabel = this->text_small->add_to_atlas(this->texts, "Categories:");
factionlabel = this->text_small->add_to_atlas(this->texts, "Faction:");
catsprites[n] = this->text_small->add_to_atlas(this->texts, "Recent");
demosprite = this->text_small->add_to_atlas(this->texts, "DEMO");
#if defined(DEBUG) && (defined(TMS_BACKEND_WINDOWS) || defined(TMS_BACKEND_LINUX))
char path[512];
@ -1697,12 +1695,6 @@ game::init_gui(void)
this->wm = new widget_manager(this, false, true);
this->info_label = new p_text(font::medium, ALIGN_CENTER, ALIGN_CENTER);
this->demo_label = new p_text(font::medium, ALIGN_CENTER, ALIGN_CENTER);
this->demo_label->active = false;
this->demo_label->set_text("Oh no! This level has reached its maximum demo time.\n"\
"Buy Principia to continue playing.");
this->demo_label->set_position(_tms.window_width/2.f, _tms.window_height/2.f);
#ifdef TMS_BACKEND_PC
this->hov_text = new p_text(font::medium, ALIGN_CENTER, ALIGN_BOTTOM);
this->hov_text->active = false;
@ -2086,16 +2078,6 @@ game::init_gui(void)
tms_assertf((ierr = glGetError()) == 0, "gl error %d in game::init_gui 10", ierr);
}
void
game::refresh_demo_label()
{
if (W->locked) {
this->demo_label->active = true;
} else {
this->demo_label->active = false;
}
}
void
game::refresh_info_label()
{
@ -2931,8 +2913,6 @@ game::render_gui(void)
return;
}
this->refresh_demo_label();
int ierr;
tms_assertf((ierr = glGetError()) == 0, "gl error %d in game::render_gui begin", ierr);
glEnable(GL_BLEND);
@ -3307,18 +3287,6 @@ game::render_gui(void)
knob_x, knob_y);
}
if (!LICENSE_IS_VALID()) {
glBindTexture(GL_TEXTURE_2D, this->texts->texture.gl_texture);
/* render DEMO label */
tms_ddraw_set_color(this->get_surface()->ddraw, 1.f, 0.f, 0.f, 1.f);
tms_ddraw_sprite(this->get_surface()->ddraw, demosprite,
_tms.window_width/2.f,
demosprite->height,
demosprite->width,
demosprite->height
);
}
glBindTexture(GL_TEXTURE_2D, 0);
glDisable(GL_BLEND);
tms_assertf((ierr = glGetError()) == 0, "gl error %d in game::render_gui end", ierr);

View file

@ -1039,7 +1039,6 @@ game::game()
, wdg_base_y(0)
, text_small(0)
, info_label(0)
, demo_label(0)
, help_dragpanel(0)
, panel_edit_need_scroll(false)
, render_controls(false)
@ -1195,9 +1194,6 @@ game::~game()
if (this->info_label) {
delete this->info_label;
}
if (this->demo_label) {
delete this->demo_label;
}
if (this->help_dragpanel) {
delete this->help_dragpanel;
}
@ -7313,11 +7309,6 @@ game::create_level(int type, bool empty, bool play)
case LCAT_CUSTOM: tms_infof("Creating a Custom level"); break;
}
if (!play && !empty && !(LICENSE_IS_VALID())) {
ui::message("Creating generated adventures not available in the DEMO version.");
return;
}
this->reset();
this->state.sandbox = !play;
this->state.test_playing = false;
@ -10628,74 +10619,7 @@ game::timed_absorb(uint32_t id, double time)
bool
game::allow_construct_entity(uint32_t g_id)
{
int num_allowed=-1;
if (!LICENSE_IS_VALID()) {
switch (g_id) { /* add restrictions to how many entities we can create of specific types
for DEMO players only */
case O_BOMBER:
case O_LOBBER:
case O_COMPANION:
case O_SPIKEBOT:
case O_ROBOT:
case O_BOMB:
case O_LANDMINE:
case O_WHEEL:
num_allowed = 8;
break;
case O_SERVO_MOTOR:
case O_DC_MOTOR:
case O_LINEAR_MOTOR:
case O_LINEAR_SERVO_MOTOR:
case O_DUMMY:
num_allowed = 6;
break;
case O_EMITTER:
case O_MINI_EMITTER:
case O_ABSORBER:
case O_MINI_ABSORBER:
case O_ROCKET:
case O_THRUSTER:
case O_ITEM:
case O_POWER_SUPPLY:
case O_RC_BASIC:
case O_RC_IO3:
case O_RC_MONSTRO:
case O_CRANE:
num_allowed = 2;
break;
case O_OILRIG:
case O_FACTORY:
case O_ROBOT_FACTORY:
case O_FLUID:
case O_SYNTHESIZER:
num_allowed = 1;
break;
case O_MULTI_EMITTER:
case O_ESCRIPT:
case O_TIMECTRL:
num_allowed = 0;
break;
}
}
if (num_allowed > -1) {
if (num_allowed == 0 || W->has_num_entities_with_gid(g_id, num_allowed)) {
if (num_allowed == 0) {
ui::messagef("DEMO version does not allow using '%s'", of::get_object_name_by_gid(g_id));
} else {
ui::messagef("DEMO version: only %d allowed object%s of type '%s'", num_allowed, num_allowed>1?"s":"", of::get_object_name_by_gid(g_id));
}
return false;
}
}
// Previously used for restricting objects in DEMO mode.
return true;
}
@ -11869,9 +11793,6 @@ game::post_render()
if (this->info_label && this->info_label->active) {
this->info_label->render(this->get_surface()->ddraw, true);
}
if (this->demo_label && this->demo_label->active) {
this->demo_label->render(this->get_surface()->ddraw, true);
}
pscreen::post_render();

View file

@ -441,7 +441,6 @@ class game : public pscreen
void refresh_widgets();
bool widget_clicked(principia_wdg *w, uint8_t button_id, int pid);
void refresh_info_label();
void refresh_demo_label();
void refresh_axis_rot();
/** Widgets **/
principia_wdg *wdg_username;
@ -485,7 +484,6 @@ class game : public pscreen
principia_wdg *wdg_freq_down;
principia_wdg *wdg_selection_slider[ENTITY_MAX_SLIDERS];
p_text *info_label;
p_text *demo_label;
principia_wdg *wdg_follow_connections;
principia_wdg *wdg_follow_cables;
principia_wdg *wdg_additive;

View file

@ -322,8 +322,6 @@ static int _publish_level(void *p);
static int _download_level(void *p);
static int _check_version_code(void *_unused);
static int _get_featured_levels(void *_unused);
static int _license_check_offline(void *_unused);
static int _license_check_online(void *_unused);
static void
gi_end(void)
@ -746,7 +744,6 @@ intermediary::window_size_changed()
}
}
uint64_t last_license_check=0;
char *featured_levels_buf = 0;
size_t featured_levels_buf_size = 0;
static int featured_levels_left = 0;
@ -784,29 +781,6 @@ tproject_step(void)
}
break;
case ACTION_LICENSE_CHECK_OFFLINE:
{
last_license_check = _tms.last_time;
create_thread(
_license_check_offline,
"_license_check_offline",
0);
}
break;
case ACTION_LICENSE_CHECK:
{
last_license_check = _tms.last_time;
create_thread(
_license_check_online,
"_license_check_online",
0);
}
break;
case ACTION_VERSION_CHECK:
create_thread(_check_version_code,"_version_check", (void*)0);
break;
@ -1351,7 +1325,6 @@ tproject_step(void)
ui::emit_signal(SIGNAL_PLAY_COMMUNITY_LEVEL);
G->resume_action = GAME_RESUME_OPEN;
G->screen_back = 0;
last_license_check = _tms.last_time;
if (_tms.screen == &P.s_loading_screen->super) {
/* we set the screen following the loading screen to an
@ -2667,25 +2640,6 @@ _check_version_code(void *_unused)
P.add_action(ACTION_REFRESH_HEADER_DATA, 0);
#if defined TMS_BACKEND_WINDOWS || defined TMS_BACKEND_LINUX
if (res != 1) {
char *u,*k,*s,*l;
P_get_cookie_data(&u, &k, &s, &l);
if (u && l) {
if (atoi(u) > 1) {
//tms_infof("logged in");
P.add_action(ACTION_LICENSE_CHECK, 0);
} else {
ui::set_next_action(ACTION_LICENSE_CHECK);
ui::open_dialog(DIALOG_LOGIN);
}
}
} else {
P.add_action(ACTION_LICENSE_CHECK_OFFLINE, 0);
}
#endif
tms_debugf("exiting version check thread");
return 0;
}
@ -4570,49 +4524,6 @@ P_get_cookie_data(char **u, char **k, char **sid, char **l)
unlock_curl("get_cookie_data");
}
static int
_license_check_offline(void *data)
{
if (P.curl) {
char *u,*k,*s,*l;
P_get_cookie_data(&u, &k, &s, &l);
lvl_progress *lvl = progress::get_level_progress(LEVEL_MAIN, LICENSE_LEVEL_ID);
if (lvl->completed && u && atoi(u) == lvl->top_score) {
/* licensed */
tms_debugf("license valid (offline)");
} else {
ui::open_dialog(DIALOG_INVALID_LICENSE);
}
}
return 0;
}
static int
_license_check_online(void *data)
{
if (P.curl) {
char *u,*k,*s,*l;
P_get_cookie_data(&u, &k, &s, &l);
tms_debugf("license check: %s", u);
if (u && l && atoi(l)>0 && atoi(u) > 1) {
lvl_progress *lvl = progress::get_level_progress(LEVEL_MAIN, LICENSE_LEVEL_ID);
lvl->completed = 1;
lvl->top_score = atoi(u);
tms_debugf("valid pc license!");
} else {
lvl_progress *lvl = progress::get_level_progress(LEVEL_MAIN, LICENSE_LEVEL_ID);
lvl->completed = 0;
tms_debugf("invalid pc license");
ui::open_dialog(DIALOG_INVALID_LICENSE);
}
}
return 0;
}
extern "C" void
P_focus(int focus)
{

View file

@ -349,7 +349,6 @@ void P_focus(int focus);
extern "C" {
#endif
void P_get_cookie_data(char **u, char **k, char **sid, char **l);
extern uint64_t last_license_check;
#ifdef __cplusplus
}
#endif

View file

@ -32,14 +32,10 @@ menu_create::widget_clicked(principia_wdg *w, uint8_t button_id, int pid)
break;
case BTN_ADVENTURE:
if (LICENSE_IS_VALID()) {
G->resume_action = GAME_RESUME_NEW;
G->resume_level_type = LCAT_ADVENTURE;
G->screen_back = 0;
tms::set_screen(G);
} else {
ui::message("Creating generated adventures not available in the DEMO version.");
}
G->resume_action = GAME_RESUME_NEW;
G->resume_level_type = LCAT_ADVENTURE;
G->screen_back = 0;
tms::set_screen(G);
break;
case BTN_EMPTY_ADVENTURE:

View file

@ -252,10 +252,7 @@ pscreen::handle_input(tms::event *ev, int action)
&& !prompt_is_open
#endif
) {
if (_tms.last_time - last_license_check >= LICENSE_CHECK_INTERVAL) {
last_license_check = _tms.last_time;
P.add_action(ACTION_VERSION_CHECK, 0);
}
P.add_action(ACTION_VERSION_CHECK, 0);
}
#endif
}

View file

@ -3925,12 +3925,6 @@ GtkButton *freq_range_ok;
GtkButton *freq_range_cancel;
GtkLabel *freq_range_info;
/** --License dialog **/
GtkDialog *license_dialog;
/** --Token dialog **/
GtkDialog *token_dialog;
/** --Login **/
GtkWindow *login_window;
GtkEntry *login_username;
@ -9093,9 +9087,6 @@ on_login_hide(GtkWidget *wdg, void *unused)
{
tms_infof("login hiding");
prompt_is_open = 0;
if (ui::next_action == ACTION_LICENSE_CHECK) {
P.add_action(ACTION_LICENSE_CHECK, 0);
}
}
gboolean
@ -11832,57 +11823,6 @@ int _gtk_loop(void *p)
gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);
}
/* invalid license dialog */
{
license_dialog = GTK_DIALOG(gtk_message_dialog_new(
0, (GtkDialogFlags)(0),/*GTK_MODAL*/
GTK_MESSAGE_INFO,
GTK_BUTTONS_NONE,
"Demo Version"));
apply_defaults(license_dialog);
GTK_BUTTON(gtk_dialog_add_button(license_dialog, "More Info", GTK_RESPONSE_ACCEPT));
GTK_BUTTON(gtk_dialog_add_button(license_dialog, GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE));
gtk_message_dialog_set_markup(GTK_MESSAGE_DIALOG(license_dialog),
"<b>Thank you for playing Principia.</b>"
"\n\n"
"This is the demo version with limited functionality."
"\n\n"
"Purchase the full version to get rid of this annoying message, and to get unlimited publishing and downloading access to the community website."
"\n\n"
"Get the full version for a discounted price by referring your friends to buy it too. Read more on the store page."
"\n\n"
);
}
/* invalid license dialog */
{
token_dialog = GTK_DIALOG(gtk_message_dialog_new(
0, (GtkDialogFlags)(0),/*GTK_MODAL*/
GTK_MESSAGE_WARNING,
GTK_BUTTONS_NONE,
"Oh no!"));
apply_defaults(token_dialog);
GTK_BUTTON(gtk_dialog_add_button(token_dialog, "More Info", GTK_RESPONSE_ACCEPT));
GTK_BUTTON(gtk_dialog_add_button(token_dialog, GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE));
gtk_message_dialog_set_markup(GTK_MESSAGE_DIALOG(token_dialog),
"<b>You have run out of download tokens :(</b>"
"\n\n"
"What to do now? Buy Principia to support our development and get unlimited access.\n"
"You can also get 10 more download tokens by referring one of your friends to install the Principia Demo. Read more by clicking the button below."
"\n\n"
);
}
/** --Multi config **/
{
multi_config_window = new_window_defaults("Multi config", &on_multi_config_show);
@ -13405,54 +13345,6 @@ _open_publish_dialog(gpointer unused)
return false;
}
static gboolean
_open_license_dialog(gpointer unused)
{
prompt_is_open = 1;
P.focused = false;
int response = (int)gtk_dialog_run(license_dialog);
P.focused = true;
prompt_is_open = 0;
switch (response) {
case GTK_RESPONSE_ACCEPT:
ui::open_url("http://" COMMUNITY_HOST "/store");
break;
default:
case GTK_RESPONSE_CLOSE:
break;
}
gtk_widget_hide(GTK_WIDGET(license_dialog));
last_license_check = _tms.last_time;
return false;
}
static gboolean
_open_token_dialog(gpointer unused)
{
prompt_is_open = 1;
P.focused = false;
int response = (int)gtk_dialog_run(token_dialog);
P.focused = true;
prompt_is_open = 0;
switch (response) {
case GTK_RESPONSE_ACCEPT:
ui::open_url("http://" COMMUNITY_HOST "/login");
break;
default:
case GTK_RESPONSE_CLOSE:
break;
}
gtk_widget_hide(GTK_WIDGET(token_dialog));
last_license_check = _tms.last_time;
return false;
}
static gboolean
_open_login_dialog(gpointer unused)
{
@ -14328,8 +14220,8 @@ _open_sfx_window(gpointer unused)
entity *e = G->selection.e;
if (e && e->g_id == O_SFX_EMITTER) {
e->set_property(0, (uint32_t)gtk_combo_box_get_active(GTK_COMBO_BOX(sfx_cb)));
e->set_property(1, (uint8_t)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(sfx_global)));
e->set_property(0, (uint32_t)gtk_combo_box_get_active(GTK_COMBO_BOX(sfx_cb)));
e->set_property(1, (uint8_t)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(sfx_global)));
}
}
break;
@ -14353,11 +14245,11 @@ _open_sfx2_window(gpointer unused)
entity *e = G->selection.e;
if (e && e->g_id == O_SFX_EMITTER) {
e->set_property(0, (uint32_t)gtk_combo_box_get_active(GTK_COMBO_BOX(sfx2_cb)));
e->set_property(1, (uint8_t)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(sfx2_global)));
e->set_property(3, (uint8_t)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(sfx2_loop)));
e->set_property(0, (uint32_t)gtk_combo_box_get_active(GTK_COMBO_BOX(sfx2_cb)));
e->set_property(1, (uint8_t)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(sfx2_global)));
e->set_property(3, (uint8_t)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(sfx2_loop)));
uint32_t active_sub = (uint32_t)gtk_combo_box_get_active(GTK_COMBO_BOX(sfx2_sub_cb));
uint32_t active_sub = (uint32_t)gtk_combo_box_get_active(GTK_COMBO_BOX(sfx2_sub_cb));
if (active_sub == 0) {
e->properties[2].v.i = SFX_CHUNK_RANDOM;
@ -14819,7 +14711,7 @@ _open_elistener_window(gpointer unused)
entity *e = G->selection.e;
if (e && e->g_id == 156) {
e->set_property(0, (uint32_t)gtk_combo_box_get_active(GTK_COMBO_BOX(elistener_cb)));
e->set_property(0, (uint32_t)gtk_combo_box_get_active(GTK_COMBO_BOX(elistener_cb)));
}
}
break;
@ -15081,8 +14973,6 @@ ui::open_dialog(int num, void *data/*=0*/)
case DIALOG_PUBLISH: gdk_threads_add_idle(_open_publish_dialog, 0); break;
case DIALOG_LOGIN: gdk_threads_add_idle(_open_login_dialog, 0); break;
case DIALOG_INVALID_LICENSE: gdk_threads_add_idle(_open_license_dialog, 0); break;
case DIALOG_OUT_OF_TOKENS: gdk_threads_add_idle(_open_token_dialog, 0); break;
case DIALOG_PROMPT:
if (G) {

View file

@ -341,17 +341,7 @@ world::step()
if (_tms.time_accum >= WORLD_STEP) {
this->step_count ++;
/* license checking, limit playtime to 20 minutes */
if (this->step_count >= 125*60*20) {
if (!(LICENSE_IS_VALID())) {
this->locked = true;
return false;
} else {
this->locked = false;
}
} else {
this->locked = false;
}
this->locked = false;
#ifdef PROFILING
Uint32 ss = SDL_GetTicks();