So, I am trying to save a struct to an appvar. However, this results in every value overflowing and just straight up going crazy. Code for Saving/Loading:
Code:
Structs:
Code:
Thanks for any help !
Code:
int load(void *Player, void *Counts, void *Prices)
{
uint8_t var = ti_Open("CEClickS", "r");
if (var == 0)
{
return 1;
}
if (ti_GetC(var) != 'a')
{
return 1;
}
if (ti_Read(Player, sizeof((*Player)), 1, var) != 1)
{
return 1;
}
if (ti_GetC(var) != 'b')
{
return 1;
}
if (ti_Read(Counts, sizeof((*Counts)), 1, var) != 1)
{
return 1;
}
if (ti_GetC(var) != 'c')
{
return 1;
}
if (ti_Read(Prices, sizeof((*Prices)), 1, var) != 1)
{
return 1;
}
ti_Close(var);
return 0;
}
int save(void* Player, void* Counts, void* Prices)
{
uint8_t var = ti_Open("CEClickS", "w");
if (ti_PutC('a', var) == EOF)
{
os_PutStrFull("a");
ti_Close(var);
return 1;
}
if (ti_Write(Player, sizeof((*Player)), 1, var) != 1)
{
os_PutStrFull("Player");
ti_Close(var);
return 1;
}
if (ti_PutC('b', var) == EOF)
{
os_PutStrFull("b");
ti_Close(var);
return 1;
}
if (ti_Write(Counts, sizeof((*Counts)), 1, var) != 1)
{
os_PutStrFull("Count");
ti_Close(var);
return 1;
}
if (ti_PutC('c', var) == EOF)
{
os_PutStrFull("c");
ti_Close(var);
return 1;
}
if (ti_Write(Prices, sizeof((*Prices)), 1, var) != 1)
{
os_PutStrFull("Price");
ti_Close(var);
return 1;
}
ti_SetArchiveStatus(true, var);
ti_Close(var);
return 0;
}
Structs:
Code:
struct player {
uint64_t points;
uint64_t cps;
uint64_t clickvalue;
uint64_t cps_mult;
uint64_t cvm;
uint8_t unlocked;
uint8_t page;
};
struct counts {
uint64_t addcount, studentcount, subcount, cookiecount, multcount, officecount, divcount, phonecount, expcount, spacecount, calccount, buttoncount;
};
struct prices
{
uint64_t addprice;
uint64_t studentprice;
uint64_t subprice;
uint64_t cookieprice;
uint64_t multprice;
uint64_t officeprice;
uint64_t divprice;
uint64_t phoneprice;
uint64_t expprice;
uint64_t spaceprice;
uint64_t calcprice;
uint64_t buttonprice;
};
Thanks for any help !