Skip to content

Commit

Permalink
Preparing for version 1.2
Browse files Browse the repository at this point in the history
- you can now use init.txt to specify a different path and filename for
the mission progress file - this may be useful if the game's main
directory is write-protected
- updated some in-game text, including fixing all references to
"template files"
- pressing space now cycles through any active "under attack" alerts
- increased the default size of the design panel
  • Loading branch information
linleyh committed Mar 31, 2017
1 parent 518f2c1 commit ed7825d
Show file tree
Hide file tree
Showing 14 changed files with 140 additions and 31 deletions.
2 changes: 1 addition & 1 deletion bin/Manual.html
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
<div style="text-align: left;"><big style="font-weight: bold;"><big><big>Liberation Circuit</big></big></big><br>
</div>
<br>Copyright 2017 Linley Henzell<br><br>
Version: 1.1<br>
Version: 1.2<br>
<br>
<h1><a class="mozTocH1" name="mozTocId524339"></a><span class="chapter"> 1. Introduction</span></h1>
<br>Liberation Circuit is a game of fighting for control of a&nbsp;computer system
Expand Down
23 changes: 20 additions & 3 deletions bin/init.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Liberation Circuit init.txt
#
# To change the game's settings, edit this file using an
# ordinary text editor.
#
# Options are:
#
# display_w (value)
Expand Down Expand Up @@ -36,9 +39,9 @@
# fullscreen
# large_fonts

display_w 1600
display_h 900
# fullscreen
# display_w 1600
# display_h 900
fullscreen
vol_music 60
vol_effect 80

Expand Down Expand Up @@ -70,6 +73,20 @@ vol_effect 80
# tries to capture the mouse in the game window during gameplay.
# May not work in Mac OSX.
#
# savefile
# By default, the game saves mission progress in the msn.dat file in the
# same directory as the executable.
# If you want the game to save this file somewhere else, you can use the
# savefile option to specify a diffent path and filename.
# example:
# savefile mission.dat
# savefile ../mission.dat
# savefile c:/games/savefiles/libcirc/msn.dat
# The path and filename can't have any spaces.
# The path is optional (e.g. the first example just saves to mission.dat in
# the execution directory) but there must be a file name.
#



# template
Expand Down
8 changes: 4 additions & 4 deletions bin/readme.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# liberation-circuit

version: 1.1
version: 1.2

This the release version of Liberation Circuit, an RTS/programming game.
This is Liberation Circuit, an RTS/programming game.

To play the prebuilt binaries on Windows, [download the latest release](https://github.com/linleyh/liberation-circuit/releases) and run `LibCirc.exe`.
To play the prebuilt binaries on Windows, [download the latest release](https://github.com/linleyh/liberation-circuit/releases) and run `LibCirc.exe`. You can change the game settings by editing init.txt.


It should compile on any OS supported by Allegro 5 - to build, compile the c files in the source directory and link with Allegro 5. More detailed instructions are below. More detail about the source file structure is at the start of m_main.c.

The executable should go in the "bin" subdirectory (the same directory as the "init.txt" file). The game requires write access to this directory to save mission progress. If this isn't okay, you can specify a path in the fopen calls at about lines 2808 and 2860 of h_story.c.
The executable should go in the "bin" subdirectory (the same directory as the "init.txt" file). By default the game will write mission progress to a file called "msn.dat" in the bin directory. If this isn't okay (e.g. if the bin directory is write-protected), you can specify a different path and filename in init.txt.

Don't try to compile the .c files in the /proc or /story subdirectories! They are code used by the game itself.

Expand Down
7 changes: 7 additions & 0 deletions src/d_code_header.c
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,13 @@ static int auto_classify_objects(struct template_struct* templ)
break;
case OBJECT_TYPE_SPIKE:
object_angle = get_object_group_angle(templ, i, j); // this is & ANGLE_MASK
if (!dcode_state.mobile)
{
write_line_to_log("Warning: the autocoder does not currently support", MLOG_COL_WARNING);
write_line_to_log("spike objects on static processes.", MLOG_COL_WARNING);
add_auto_class_to_object(templ, i, j, AUTO_CLASS_SPIKE_FRONT); // just assign it to the class anyway.
break;
}
if (object_angle < ANGLE_4
|| object_angle > ANGLE_2 + ANGLE_4) // could adjust a little bit more?
add_auto_class_to_object(templ, i, j, AUTO_CLASS_SPIKE_FRONT);
Expand Down
6 changes: 3 additions & 3 deletions src/d_draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ add_design_bquad(POWER_GRAPH_X,
al_draw_textf(font[FONT_BASIC].fnt, colours.base [COL_GREY] [SHADE_MED], base_x2 - 4, base_y1 + scaleUI_y(FONT_BASIC, 3), ALLEGRO_ALIGN_RIGHT, "This template has been modified.");
al_draw_textf(font[FONT_BASIC].fnt, colours.base [COL_GREY] [SHADE_MED], base_x2 - 4, base_y1 + scaleUI_y(FONT_BASIC, 16), ALLEGRO_ALIGN_RIGHT, "Use <Write Header> or <Autocode>");
al_draw_textf(font[FONT_BASIC].fnt, colours.base [COL_GREY] [SHADE_MED], base_x2 - 4, base_y1 + scaleUI_y(FONT_BASIC, 29), ALLEGRO_ALIGN_RIGHT, "to keep changes.");
al_draw_textf(font[FONT_BASIC].fnt, colours.base [COL_GREY] [SHADE_MED], base_x2 - 4, base_y1 + scaleUI_y(FONT_BASIC, 42), ALLEGRO_ALIGN_RIGHT, "(Then save changes to disk using the");
al_draw_textf(font[FONT_BASIC].fnt, colours.base [COL_GREY] [SHADE_MED], base_x2 - 4, base_y1 + scaleUI_y(FONT_BASIC, 42), ALLEGRO_ALIGN_RIGHT, "(Save changes to disk using the");
al_draw_textf(font[FONT_BASIC].fnt, colours.base [COL_GREY] [SHADE_MED], base_x2 - 4, base_y1 + scaleUI_y(FONT_BASIC, 55), ALLEGRO_ALIGN_RIGHT, "File menu in the Editor [Ed] panel)");

/*
Expand Down Expand Up @@ -1307,7 +1307,7 @@ const char* object_description [OBJECT_TYPES] [3] =
"Multiple build objects speed recovery time after building.",
""}, // OBJECT_TYPE_BUILD,
{"Generates an interface to protect the process.",
"However, the interface does not protect any component",
"The interface protects all components, except components",
"with either an interface object or a move object."}, // OBJECT_TYPE_INTERFACE,
// {"Provides an interface buffer for use by interface objects.",
// "Multiple depth objects increase the size and recovery", // OBJECT_TYPE_INTERFACE_DEPTH,
Expand All @@ -1331,7 +1331,7 @@ const char* object_description [OBJECT_TYPES] [3] =
"an interface. Can rotate to track its target."}, // OBJECT_TYPE_STREAM_DIR,
{"Long-range attacking object. Does full damage only near",
"maximum range.",
""}, // OBJECT_TYPE_SPIKE,
"* The autocoder doesn't support spikes on static processes."}, // OBJECT_TYPE_SPIKE,
{"Repairs damage to components of this process, and restores",
"destroyed components. Multiple repair objects speed up",
"repair, and reduce recovery time after restoring."}, // OBJECT_TYPE_REPAIR,
Expand Down
4 changes: 3 additions & 1 deletion src/g_header.h
Original file line number Diff line number Diff line change
Expand Up @@ -2095,7 +2095,9 @@ struct settingsstruct

int saved_story_mission_defeated [STORY_TYPES] [MISSIONS]; // 0 not defeated, 1 defeated. This should match the state of the msn.dat file.

char path_to_executable [FILE_PATH_LENGTH]; // set in g_misc
char path_to_msn_dat_file [FILE_PATH_LENGTH];

char path_to_executable [FILE_PATH_LENGTH]; // set in g_misc (not currently implemented)

};

Expand Down
10 changes: 5 additions & 5 deletions src/h_story.c
Original file line number Diff line number Diff line change
Expand Up @@ -2817,7 +2817,7 @@ void load_story_status_file(void)
FILE *missionfile;
char buffer [MISSIONFILE_SIZE];

missionfile = fopen("msn.dat", "rb");
missionfile = fopen(settings.path_to_msn_dat_file, "rb");

if (!missionfile)
{
Expand All @@ -2830,7 +2830,7 @@ void load_story_status_file(void)
if (ferror(missionfile)
|| read_in == 0)
{
fprintf(stdout, "\nFailed to read mission status from msn.dat. Starting with default mission status.");
fprintf(stdout, "\nFailed to read mission status from [%s]. Starting with default mission status.", settings.path_to_msn_dat_file);
fclose(missionfile);
return;
}
Expand Down Expand Up @@ -2869,11 +2869,11 @@ void save_story_status_file(void)
FILE *file;

// open the file:
file = fopen("msn.dat", "wb");
file = fopen(settings.path_to_msn_dat_file, "wb");

if (!file)
{
fprintf(stdout, "\nFailed to save mission status to msn.dat: couldn't open file.");
fprintf(stdout, "\nFailed to save mission status to [%s]: couldn't open file.", settings.path_to_msn_dat_file);
return;
}

Expand All @@ -2893,7 +2893,7 @@ void save_story_status_file(void)

if (written != buffer_pos)
{
fprintf(stdout, "\nFailed to save mission status to msn.dat: couldn't write data (tried to write %i; wrote %i).", buffer_pos, written);
fprintf(stdout, "\nFailed to save mission status to [%s]: couldn't write data (tried to write %i; wrote %i).", settings.path_to_msn_dat_file, buffer_pos, written);
fclose(file);
return;
}
Expand Down
63 changes: 63 additions & 0 deletions src/i_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,16 @@

void initialise_control(void);
void run_mouse_drag(void);
void go_to_under_attack_marker(void);

extern struct game_struct game;
extern struct view_struct view;
extern struct command_struct command;

struct control_struct control;



// this array indicates which allegro_key enum corresponds to each KEY_? enum. Used for allowing system/clob programs to access keyboard
int corresponding_allegro_key [KEYS] =
{
Expand Down Expand Up @@ -568,6 +571,11 @@ void run_input(void)
}


if (ex_control.unichar_input == ' ')
{
go_to_under_attack_marker();
}

if (ex_control.unichar_input == 'p') // fix!
{
if (game.pause_soft == 0)
Expand Down Expand Up @@ -642,6 +650,61 @@ fpr("\n resetting music - area %i seed %i", game.area_index, mrand_seed);

}

void go_to_under_attack_marker(void)
{

if (view.under_attack_marker_last_time < w.world_time - UNDER_ATTACK_MARKER_DURATION)
return; // no current markers

int i;

int current_marker = -1;
al_fixed closest_distance = view.centre_x_zoomed;
int distance_from_camera;

for (i = 0; i < UNDER_ATTACK_MARKERS; i ++)
{
if (view.under_attack_marker [i].time_placed_world >= w.world_time - UNDER_ATTACK_MARKER_DURATION)
{
distance_from_camera = abs(view.camera_x - view.under_attack_marker[i].position.x) + abs(view.camera_y - view.under_attack_marker[i].position.y);
if (distance_from_camera < closest_distance)
{
closest_distance = distance_from_camera;
current_marker = i;
}
}
}

// current_marker may be -1 at this point

i = current_marker + 1;

while(i < UNDER_ATTACK_MARKERS - 1)
{
if (view.under_attack_marker [i].time_placed_world >= w.world_time - UNDER_ATTACK_MARKER_DURATION)
{
view.camera_x = view.under_attack_marker[i].position.x;
view.camera_y = view.under_attack_marker[i].position.y;
return;
}
i++;
}

i = 0;

while(i < current_marker)
{
if (view.under_attack_marker [i].time_placed_world >= w.world_time - UNDER_ATTACK_MARKER_DURATION)
{
view.camera_x = view.under_attack_marker[i].position.x;
view.camera_y = view.under_attack_marker[i].position.y;
return;
}
i++;
}


}

// called if mouse_drag != MOUSE_DRAG_NONE
void run_mouse_drag(void)
Expand Down
1 change: 1 addition & 0 deletions src/m_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "m_maths.h"

#include "m_input.h"
#include "x_sound.h"

extern struct editorstruct editor;
extern struct view_struct view;
Expand Down
23 changes: 17 additions & 6 deletions src/m_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ void init_at_startup(void)

fprintf(stdout, "Liberation Circuit");
fprintf(stdout, "\nCopyright 2017 Linley Henzell");
fprintf(stdout, "\nVersion 1.1");
fprintf(stdout, "\nVersion 1.2");

fprintf(stdout, "\n\nThis is free software and comes with no warranty; see licence.txt.");

Expand All @@ -428,13 +428,9 @@ fpr("\nInitialising:");
// fpr("\n al_ftofix(0.41) = %i", al_ftofix(0.41)); = 26870
// fpr("\n al_ftofix(0.94124) = %i", al_ftofix(0.94124)); = 61685


// al_set_new_display_option(ALLEGRO_SAMPLE_BUFFERS, 1, ALLEGRO_SUGGEST);
// al_set_new_display_option(ALLEGRO_SAMPLES, 2, ALLEGRO_SUGGEST);
// These might be nice, but cause strange behaviour and segfaults on my development computer.

// al_set_new_display_flags(ALLEGRO_FULLSCREEN);

// most of these can be overridden by options in init.txt
settings.option [OPTION_WINDOW_W] = 1024;
settings.option [OPTION_WINDOW_H] = 768;
settings.option [OPTION_FULLSCREEN] = 0;
Expand All @@ -448,6 +444,7 @@ fpr("\nInitialising:");
settings.option [OPTION_CAPTURE_MOUSE] = 0;
settings.option [OPTION_DOUBLE_FONTS] = 0;
settings.option [OPTION_LARGE_FONTS] = 0;
strcpy(settings.path_to_msn_dat_file, "msn.dat");

init_key_maps(); // must be before read_initfile() as keys may be remapped

Expand Down Expand Up @@ -1009,6 +1006,20 @@ static int default_templates_loaded [PLAYERS] = {0,0,0,0};
}


if (strcmp(initfile_word, "savefile") == 0)
{
// read file name:
char read_savefile_path [INITFILE_WORD_LENGTH]; // currently INITFILE_WORD_LENGTH should be FILE_PATH_LENGTH
bpos = read_initfile_word(read_savefile_path, buffer, buffer_length, bpos);
if (bpos == -1)
return -1;
strncpy(settings.path_to_msn_dat_file, read_savefile_path, FILE_PATH_LENGTH - 5);
fpr("\nSave file set to [%s].", settings.path_to_msn_dat_file);
// the file will actually be loaded at a later stage of initialisation.
return bpos;
}


if (strcmp(initfile_word, "keymap") == 0)
{
fpr("\n found keymap ");
Expand Down
3 changes: 2 additions & 1 deletion src/p_draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -484,14 +484,15 @@ static void print_sysmenu_help(float base_x, float base_y)
print_sysmenu_line("PAUSE", "P to pause/unpause", 1);
print_sysmenu_line("PAUSE ADVANCE", "[ to advance 1 frame", 1);
print_sysmenu_line("FOLLOW", "f to follow selected process", 1);
print_sysmenu_line("GO TO ALERT", "space to cycle through <under attack> alerts", 1);
print_sysmenu_line("DEBUG MODE", "F1 to toggle debug mode", 1);
print_sysmenu_line("FAST FORWARD", "F2, F3 and F4 to toggle different speeds", 1);
// print_sysmenu_line("FF (SKIP)", "F3 to toggle extra fast forward (skips frames).");
// print_sysmenu_line("FF (ND)", "F4 to toggle super fast forward (no display).");
print_sysmenu_line("CHANGE PLAYER", "F5 to change player (custom game only)", 1);
print_sysmenu_line("PANELS", "F6, F7 and F8 to open/close Te/De/Ed panels", 1);
print_sysmenu_line("ZOOM", "Use mousewheel to zoom in/out", 1);
print_sysmenu_line("QUIT", "Escape to quit program entirely", 1);
print_sysmenu_line("CHANGE PLAYER", "F5 to change player (custom game only)", 1);


}
Expand Down
4 changes: 3 additions & 1 deletion src/p_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,9 @@ void init_panels(void)

panel[PANEL_EDITOR].w = scaleUI_x(FONT_BASIC,400);
panel[PANEL_TEMPLATE].w = scaleUI_x(FONT_SQUARE,340);
panel[PANEL_DESIGN].w = scaleUI_x(FONT_SQUARE,540);
panel[PANEL_DESIGN].w = scaleUI_x(FONT_SQUARE,800);
if (panel[PANEL_DESIGN].w > 1000)
panel[PANEL_DESIGN].w = 1000;

panel[0].open = 1;
panel[0].w = inter.display_w;
Expand Down
2 changes: 1 addition & 1 deletion src/s_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -2481,7 +2481,7 @@ void run_intro_screen(void)
al_draw_textf(font[FONT_SQUARE_LARGE].fnt, colours.base [COL_GREY] [SHADE_MAX], settings.option [OPTION_WINDOW_W] / 2, START_BOX_Y - 4, ALLEGRO_ALIGN_CENTRE, ">> START <<");

y_line = scaleUI_y(FONT_SQUARE,100);
al_draw_textf(font[FONT_SQUARE].fnt, colours.base [COL_GREY] [SHADE_HIGH], settings.option [OPTION_WINDOW_W] - 50, settings.option [OPTION_WINDOW_H] - y_line, ALLEGRO_ALIGN_RIGHT, "version 1.1");
al_draw_textf(font[FONT_SQUARE].fnt, colours.base [COL_GREY] [SHADE_HIGH], settings.option [OPTION_WINDOW_W] - 50, settings.option [OPTION_WINDOW_H] - y_line, ALLEGRO_ALIGN_RIGHT, "version 1.2");
y_line -= scaleUI_y(FONT_SQUARE,25);
al_draw_textf(font[FONT_SQUARE].fnt, colours.base [COL_GREY] [SHADE_HIGH], settings.option [OPTION_WINDOW_W] - 50, settings.option [OPTION_WINDOW_H] - y_line, ALLEGRO_ALIGN_RIGHT, "Copyright 2017 Linley Henzell");
y_line -= scaleUI_y(FONT_SQUARE,15);
Expand Down
15 changes: 10 additions & 5 deletions src/t_files.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,10 @@ void save_template_file(int player_index)
return;
}

write_line_to_log("Template file saved.", MLOG_COL_TEMPLATE);
write_line_to_log("Multi-binary file saved.", MLOG_COL_TEMPLATE);
write_line_to_log("* Note: multi-binaries are for multiplayer games.", MLOG_COL_WARNING);
write_line_to_log(" To save individual processes, use the file", MLOG_COL_WARNING);
write_line_to_log(" menu in the editor panel.", MLOG_COL_WARNING);

// success!

Expand Down Expand Up @@ -457,16 +460,18 @@ void load_template_file(int player_index)
templ[player_index][i].modified = 0; // this was probably done in one of the functions above but can't hurt to do it again
templ[player_index][i].source_edit->active = 1;
templ[player_index][i].source_edit->saved = 1;
strcpy(templ[player_index][i].source_edit->text [0], "// this file was loaded from a template file, ");
strcpy(templ[player_index][i].source_edit->text [0], "// this file was loaded from a multi-binary file, ");
strcpy(templ[player_index][i].source_edit->text [1], "// and does not have source code. ");
// clear_source_edit_struct() call above reset the line index, so text[0] is the first line


}


write_line_to_log("Template file loaded.", MLOG_COL_TEMPLATE);

write_line_to_log("Multi-binary file loaded.", MLOG_COL_TEMPLATE);
write_line_to_log("* Note: multi-binaries are for multiplayer games.", MLOG_COL_WARNING);
write_line_to_log(" To load individual processes, load their .c files", MLOG_COL_WARNING);
write_line_to_log(" using the file menu in the editor panel.", MLOG_COL_WARNING);
// success!

}
Expand Down Expand Up @@ -638,7 +643,7 @@ static int choose_template_file(int filechooser_mode)

if (file_type != FILE_TYPE_TEMPLATE)
{
write_line_to_log("Must be a template file with the .tf extension.", MLOG_COL_ERROR);
write_line_to_log("Must be a multi-binary template file with the .tf extension.", MLOG_COL_ERROR);
}

strcpy(tfile.template_file_path, file_path_ptr);
Expand Down

0 comments on commit ed7825d

Please sign in to comment.