///////////////////////////////////////////////////////////////////
// headers.h - headers file for test
typedef struct test_struct
{ var value1;
var value2;
STRING* str1;
STRING* str2;
STRING* str3;
struct test_struct* next;
} test_struct;
typedef struct save_struct
{ var value1;
var value2;
var str1;
var str2;
var str3;
struct save_struct* next;
} save_struct;
test_struct* first_struct;
test_struct* curr_struct;
save_struct* first_save;
save_struct* curr_save;
var test;
var test2;
//////////////////////////////////////////////////////////////////////
// test.c
#include <acknex.h>
#include <default.c>
#include "headers.h"
FONT* standard_font = "ackfont.pcx";
PANEL* info_panel =
{ pos_x = 20;
pos_y = 20;
flags = SHOW;
digits = 0,0,3.0,standard_font,1,test;
digits = 0,10,3.0,standard_font,1,test2;
}
TEXT* info_text =
{ pos_x = 20;
pos_y = 40;
flags = SHOW;
font = standard_font;
strings = 3;
string(" "," "," ");
}
TEXT* status_text =
{ pos_x = 20;
pos_y = 70;
flags = SHOW;
font = standard_font;
strings = 1;
string("Status: N/A");
}
function save_game()
{ str_cat(first_struct->str1," ");
str_cat(first_struct->str2," ");
str_cat(first_struct->str3," ");
first_save->value1 = first_struct->value1;
first_save->value2 = first_struct->value2;
first_save->str1 = handle(first_struct->str1);
first_save->str2 = handle(first_struct->str2);
first_save->str3 = handle(first_struct->str3);
add_struct(first_save,sizeof(save_struct));
game_save("test",1,SV_ALL);
str_cpy((status_text.pstring)[0],"Status: Game Saved.");
}
function mem_clear()
{ first_struct->value1 = 0;
first_struct->value2 = 0;
str_cpy(first_struct->str1," ");
str_cpy(first_struct->str2," ");
str_cpy(first_struct->str3," ");
first_save->value1 = 0;
first_save->value2 = 0;
first_save->str1 = 0;
first_save->str2 = 0;
first_save->str3 = 0;
str_cpy((status_text.pstring)[0],"Status: Memory Cleared.");
}
function load_game()
{ game_load("test",1);
first_struct->value1 = first_save->value1;
first_struct->value2 = first_save->value2;
first_struct->str1 = ptr_for_handle(first_save->str1);
first_struct->str2 = ptr_for_handle(first_save->str2);
first_struct->str3 = ptr_for_handle(first_save->str3);
str_cpy((status_text.pstring)[0],"Status: Game Loaded.");
}
function main()
{ on_f1 = save_game;
on_f2 = mem_clear;
on_f3 = load_game;
first_struct = (test_struct*)malloc(sizeof(test_struct));
first_struct->value1 = 5;
first_struct->value2 = 10;
first_struct->str1 = str_create("This is the first str");
first_struct->str2 = str_create("This is the second str");
first_struct->str3 = str_create("This is the third str");
first_struct->next = NULL;
first_save = (save_struct*)malloc(sizeof(save_struct));
first_save->value1 = 0;
first_save->value2 = 0;
first_save->str1 = 0;
first_save->str2 = 0;
first_save->str3 = 0;
first_save->next = NULL;
while(key_esc==0)
{ test = first_struct->value1;
test2 = first_struct->value2;
(info_text.pstring)[0] = first_struct->str1;
(info_text.pstring)[1] = first_struct->str2;
(info_text.pstring)[2] = first_struct->str3;
wait(1);
}
}