2011-12-10 13:25:22 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2012-01-24 13:16:20 +00:00
|
|
|
#include "auto.h"
|
|
|
|
#include "system.h"
|
|
|
|
#include "scenery.h"
|
|
|
|
#include "render.h"
|
2012-04-28 13:36:37 +00:00
|
|
|
#include "main.h"
|
2012-12-01 16:39:47 +00:00
|
|
|
#include "opencl.h"
|
2012-04-28 13:36:37 +00:00
|
|
|
|
2012-06-15 09:31:11 +00:00
|
|
|
#define APP_HEADER 198632.125
|
2011-12-10 13:25:22 +00:00
|
|
|
|
2011-12-23 22:39:13 +00:00
|
|
|
void paysagesInit()
|
2011-12-10 13:25:22 +00:00
|
|
|
{
|
2012-01-07 16:53:23 +00:00
|
|
|
systemInit();
|
2012-12-01 16:39:47 +00:00
|
|
|
openclInit();
|
2011-12-10 13:25:22 +00:00
|
|
|
|
2012-01-24 13:16:20 +00:00
|
|
|
sceneryInit();
|
2012-01-22 18:39:42 +00:00
|
|
|
renderInit();
|
2011-12-18 21:59:33 +00:00
|
|
|
|
2011-12-10 13:25:22 +00:00
|
|
|
autoGenRealisticLandscape(0);
|
|
|
|
}
|
2012-01-22 18:39:42 +00:00
|
|
|
|
2012-02-12 16:57:29 +00:00
|
|
|
void paysagesQuit()
|
|
|
|
{
|
|
|
|
sceneryQuit();
|
|
|
|
renderQuit();
|
2012-12-24 15:15:40 +00:00
|
|
|
|
2012-12-01 16:39:47 +00:00
|
|
|
openclQuit();
|
2012-02-12 16:57:29 +00:00
|
|
|
}
|
|
|
|
|
2012-04-28 13:36:37 +00:00
|
|
|
FileOperationResult paysagesSave(char* filepath)
|
2012-01-22 18:39:42 +00:00
|
|
|
{
|
2012-04-28 13:36:37 +00:00
|
|
|
PackStream* stream = packWriteFile(filepath);
|
2012-06-17 09:40:40 +00:00
|
|
|
double app_header, version_header;
|
2012-12-24 15:15:40 +00:00
|
|
|
|
2012-04-28 13:36:37 +00:00
|
|
|
if (!stream)
|
|
|
|
{
|
|
|
|
return FILE_OPERATION_IOERROR;
|
|
|
|
}
|
2012-12-24 15:15:40 +00:00
|
|
|
|
2012-06-17 09:40:40 +00:00
|
|
|
app_header = (double)APP_HEADER;
|
|
|
|
packWriteDouble(stream, &app_header);
|
|
|
|
version_header = (double)PAYSAGES_CURRENT_DATA_VERSION;
|
|
|
|
packWriteDouble(stream, &version_header);
|
2012-12-24 15:15:40 +00:00
|
|
|
|
2012-04-28 13:36:37 +00:00
|
|
|
scenerySave(stream);
|
2012-12-24 15:15:40 +00:00
|
|
|
|
2012-04-28 13:36:37 +00:00
|
|
|
packCloseStream(stream);
|
2012-12-24 15:15:40 +00:00
|
|
|
|
2012-04-28 13:36:37 +00:00
|
|
|
return FILE_OPERATION_OK;
|
2012-01-22 18:39:42 +00:00
|
|
|
}
|
|
|
|
|
2012-04-28 13:36:37 +00:00
|
|
|
FileOperationResult paysagesLoad(char* filepath)
|
2012-01-22 18:39:42 +00:00
|
|
|
{
|
2012-04-28 13:36:37 +00:00
|
|
|
PackStream* stream = packReadFile(filepath);
|
2012-06-17 09:40:40 +00:00
|
|
|
double app_header, version_header;
|
2012-04-28 13:36:37 +00:00
|
|
|
|
|
|
|
if (!stream)
|
|
|
|
{
|
|
|
|
return FILE_OPERATION_IOERROR;
|
|
|
|
}
|
|
|
|
|
2012-06-17 09:40:40 +00:00
|
|
|
packReadDouble(stream, &app_header);
|
2012-04-28 13:36:37 +00:00
|
|
|
if (app_header != APP_HEADER)
|
|
|
|
{
|
|
|
|
packCloseStream(stream);
|
|
|
|
return FILE_OPERATION_APP_MISMATCH;
|
|
|
|
}
|
2012-12-24 15:15:40 +00:00
|
|
|
|
2012-06-17 09:40:40 +00:00
|
|
|
packReadDouble(stream, &version_header);
|
2012-04-28 13:36:37 +00:00
|
|
|
if ((int)version_header != PAYSAGES_CURRENT_DATA_VERSION)
|
|
|
|
{
|
|
|
|
packCloseStream(stream);
|
|
|
|
return FILE_OPERATION_VERSION_MISMATCH;
|
|
|
|
}
|
|
|
|
|
|
|
|
sceneryLoad(stream);
|
|
|
|
|
|
|
|
packCloseStream(stream);
|
2012-12-24 15:15:40 +00:00
|
|
|
|
2012-04-28 13:36:37 +00:00
|
|
|
return FILE_OPERATION_OK;
|
2012-01-22 18:39:42 +00:00
|
|
|
}
|