How do I save the contents of a structure with game_save()?

I have the following, which doesnt quite work:
Code:
<headers.h>
typedef struct test_struct
{   var value1;
    var value2;
    STRING* str1;
    STRING* str2;
    STRING* str3;
    struct test_struct* next;
} test_struct;

test_struct* first_struct;
test_struct* curr_struct;

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()
{   game_save("test",1,SV_VARS+SV_STRUCT); 
    str_cpy((status_text.pstring)[0],"Status: Game Saved.");
}

function load_game()
{   str_remove(first_struct->str1);
    str_remove(first_struct->str2);
    str_remove(first_struct->str3);
    free(first_struct);
    game_load("test",1);
    str_cpy((status_text.pstring)[0],"Status: Game Loaded.");
}

function main()
{   on_f1 = save_game;
    on_f2 = load_game;
    first_struct = (test_struct*)malloc(sizeof(test_struct));
    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->value1 = 5;
    first_struct->value2 = 10;
    first_struct->next = NULL;
    add_struct(first_struct,sizeof(test_struct));
    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);
    }
}


when i do a game_save() with this code, it saves first_struct->value1 & value2, and it saves the *pointers* to str1, str2, and str3, but it does not save the strings themselves. (IE when i load the game first_struct->str1 isnt equal to "This is the first str" - it is equal to whatever garbage happens to be in the memory area that the str pointer is pointing at)

Last edited by Caermundh; 03/14/11 00:20.