saveload.c
changeset 4077 d3022f976946
parent 4059 f1442dfe1c8a
child 4255 5cb4bcf7c83f
equal deleted inserted replaced
4076:e3ef1c1f149c 4077:d3022f976946
   564 
   564 
   565 	/* NOTICE - handle some buggy stuff, in really old versions everything was saved
   565 	/* NOTICE - handle some buggy stuff, in really old versions everything was saved
   566 	 * as a byte-type. So detect this, and adjust array size accordingly */
   566 	 * as a byte-type. So detect this, and adjust array size accordingly */
   567 	if (!_sl.save && _sl_version == 0) {
   567 	if (!_sl.save && _sl_version == 0) {
   568 		if (conv == SLE_INT16 || conv == SLE_UINT16 || conv == SLE_STRINGID ||
   568 		if (conv == SLE_INT16 || conv == SLE_UINT16 || conv == SLE_STRINGID ||
   569 			  conv == SLE_INT32 || conv == SLE_UINT32) {
   569 				conv == SLE_INT32 || conv == SLE_UINT32) {
   570 			length *= SlCalcConvFileLen(conv);
   570 			length *= SlCalcConvFileLen(conv);
   571 			conv = SLE_INT8;
   571 			conv = SLE_INT8;
   572 		}
   572 		}
   573 	}
   573 	}
   574 
   574 
  1406 	if (setjmp(_sl.excpt)) {
  1406 	if (setjmp(_sl.excpt)) {
  1407 		AbortSaveLoad();
  1407 		AbortSaveLoad();
  1408 		_sl.excpt_uninit();
  1408 		_sl.excpt_uninit();
  1409 
  1409 
  1410 		fprintf(stderr, "Save game failed: %s.", _sl.excpt_msg);
  1410 		fprintf(stderr, "Save game failed: %s.", _sl.excpt_msg);
  1411 		if (arg != NULL) OTTD_SendThreadMessage(MSG_OTTD_SAVETHREAD_ERROR);
  1411 		if (arg != NULL) {
  1412 		else SaveFileError();
  1412 			OTTD_SendThreadMessage(MSG_OTTD_SAVETHREAD_ERROR);
       
  1413 		} else {
       
  1414 			SaveFileError();
       
  1415 		}
  1413 		return NULL;
  1416 		return NULL;
  1414 	}
  1417 	}
  1415 
  1418 
  1416 	fmt = GetSavegameFormat(_savegame_format);
  1419 	fmt = GetSavegameFormat(_savegame_format);
  1417 
  1420 
  1631 
  1634 
  1632 	f = fopen(file, "rb");
  1635 	f = fopen(file, "rb");
  1633 	if (fread(&hdr, sizeof(hdr), 1, f) != 1) {
  1636 	if (fread(&hdr, sizeof(hdr), 1, f) != 1) {
  1634 		printf("Savegame is obsolete or invalid format.\n");
  1637 		printf("Savegame is obsolete or invalid format.\n");
  1635 		mode = SL_LOAD; // don't try to get filename, just show name as it is written
  1638 		mode = SL_LOAD; // don't try to get filename, just show name as it is written
  1636 	}
  1639 	} else {
  1637 	else {
       
  1638 		// see if we have any loader for this type.
  1640 		// see if we have any loader for this type.
  1639 		for (fmt = _saveload_formats; fmt != endof(_saveload_formats); fmt++) {
  1641 		for (fmt = _saveload_formats; fmt != endof(_saveload_formats); fmt++) {
  1640 			if (fmt->tag == hdr) {
  1642 			if (fmt->tag == hdr) {
  1641 				mode = SL_LOAD; // new type of savegame
  1643 				mode = SL_LOAD; // new type of savegame
  1642 				break;
  1644 				break;