equal
deleted
inserted
replaced
93 throw std::exception(); |
93 throw std::exception(); |
94 } |
94 } |
95 |
95 |
96 typedef void (*AsyncSaveFinishProc)(); |
96 typedef void (*AsyncSaveFinishProc)(); |
97 static AsyncSaveFinishProc _async_save_finish = NULL; |
97 static AsyncSaveFinishProc _async_save_finish = NULL; |
|
98 static ThreadObject *_save_thread; |
98 |
99 |
99 /** |
100 /** |
100 * Called by save thread to tell we finished saving. |
101 * Called by save thread to tell we finished saving. |
101 */ |
102 */ |
102 static void SetAsyncSaveFinish(AsyncSaveFinishProc proc) |
103 static void SetAsyncSaveFinish(AsyncSaveFinishProc proc) |
115 if (_async_save_finish == NULL) return; |
116 if (_async_save_finish == NULL) return; |
116 |
117 |
117 _async_save_finish(); |
118 _async_save_finish(); |
118 |
119 |
119 _async_save_finish = NULL; |
120 _async_save_finish = NULL; |
|
121 |
|
122 if (_save_thread != NULL) { |
|
123 _save_thread->Join(); |
|
124 delete _save_thread; |
|
125 _save_thread = NULL; |
|
126 } |
120 } |
127 } |
121 |
128 |
122 /** |
129 /** |
123 * Fill the input buffer by reading from the file with the given reader |
130 * Fill the input buffer by reading from the file with the given reader |
124 */ |
131 */ |
1543 SetDParamStr(0, GetSaveLoadErrorString()); |
1550 SetDParamStr(0, GetSaveLoadErrorString()); |
1544 ShowErrorMessage(STR_012D, STR_NULL, 0, 0); |
1551 ShowErrorMessage(STR_012D, STR_NULL, 0, 0); |
1545 SaveFileDone(); |
1552 SaveFileDone(); |
1546 } |
1553 } |
1547 |
1554 |
1548 static ThreadObject *_save_thread; |
|
1549 |
|
1550 /** We have written the whole game into memory, _Savegame_pool, now find |
1555 /** We have written the whole game into memory, _Savegame_pool, now find |
1551 * and appropiate compressor and start writing to file. |
1556 * and appropiate compressor and start writing to file. |
1552 */ |
1557 */ |
1553 static SaveOrLoadResult SaveFileToDisk(bool threaded) |
1558 static SaveOrLoadResult SaveFileToDisk(bool threaded) |
1554 { |
1559 { |
1615 void WaitTillSaved() |
1620 void WaitTillSaved() |
1616 { |
1621 { |
1617 if (_save_thread == NULL) return; |
1622 if (_save_thread == NULL) return; |
1618 |
1623 |
1619 _save_thread->Join(); |
1624 _save_thread->Join(); |
|
1625 delete _save_thread; |
1620 _save_thread = NULL; |
1626 _save_thread = NULL; |
1621 } |
1627 } |
1622 |
1628 |
1623 /** |
1629 /** |
1624 * Main Save or Load function where the high-level saveload functions are |
1630 * Main Save or Load function where the high-level saveload functions are |