bool MapFile::SaveFile(bool SaveAs) { if ( isProtected() ) MessageBox(NULL, "Cannot save protected maps!", "Error!", MB_OK|MB_ICONEXCLAMATION); else { if ( SaveAs || filePath[0] == '\0' ) // SaveAs specified or filePath not yet determined { OPENFILENAME ofn = GetScSaveOfn(filePath); if ( GetSaveFileName(&ofn) ) { SaveType = (u8)ofn.nFilterIndex; char* ext = std::strrchr(filePath, '.'); // Find the last occurrence of '.' if ( ext == nullptr ) // No extension specified, need to add { if ( SaveType == 1 || SaveType == 2 ) std::strcat(filePath, ".scm"); else if ( SaveType == 3 || SaveType == 7 ) std::strcat(filePath, ".scx"); else if ( SaveType >= 4 && SaveType <= 6 ) std::strcat(filePath, ".chk"); } else // Extension specified, give it precedence over filterIndex { if ( std::strcmp(ext, ".chk") == 0 && SaveType < 4 ) SaveType = 5; else if ( std::strcmp(ext, ".scm") == 0 && SaveType > 1 ) SaveType = 2; else if ( std::strcmp(ext, ".scx") == 0 ) SaveType = 3; else if ( SaveType == 7 ) SaveType = 3; } } } if ( filePath[0] != '\0' ) // Map for sure has a path { FILE* pFile(nullptr); if ( SaveType == 1 || SaveType == 4 ) // StarCraft Map, edit to match { TYPE().overwrite("RAWS", 4); VER ().overwrite(";\0", 2); IVER().overwrite("\12\0", 2); IVE2().overwrite("\13\0", 2); if ( MRGN().size() > 1280 ) // If there's over 64 locations MRGN().delRange(1280, MRGN().size()); // Remove the extras } else if ( SaveType == 2 || SaveType == 5 ) // Hybrid Map, edit to match { TYPE().overwrite("RAWS", 4); VER ().overwrite("?\0", 2); IVER().overwrite("\12\0", 2); IVE2().overwrite("\13\0", 2); if ( MRGN().size() < 5100 ) // If there's < 255 locations MRGN().add<u8>(0, 5100-MRGN().size()); // Add space for 255 } else if ( SaveType == 3 || SaveType == 6 || SaveType == 7 ) // BroodWar Map, edit to match { TYPE().overwrite("RAWB", 4); VER ().overwrite("Í\0", 2); RemoveSection(SectionId::IVER); IVE2().overwrite("\13\0", 2); if ( MRGN().size() < 5100 ) // If there's < 255 locations MRGN().add<u8>(0, 5100-MRGN().size()); // Add space for 255 } if ( (SaveType > 0 && SaveType <= 3) || SaveType == 7 ) // Must be packed into an MPQ { pFile = std::fopen(filePath, "wb"); if ( pFile != nullptr ) { std::fclose(pFile); HANDLE hMpq = NULL; DeleteFileA("chk.tmp"); // Remove any existing chk.tmp files pFile = std::fopen("chk.tmp", "wb"); WriteFile(pFile); std::fclose(pFile); hMpq = MpqOpenArchiveForUpdate(filePath, MOAU_OPEN_ALWAYS|MOAU_MAINTAIN_LISTFILE, 16); if ( hMpq != NULL && hMpq != INVALID_HANDLE_VALUE ) { BOOL addedFile = MpqAddFileToArchive(hMpq, "chk.tmp", "staredit\\scenario.chk", MAFA_COMPRESS | MAFA_REPLACE_EXISTING); MpqCloseUpdatedArchive(hMpq, 0); if ( addedFile == TRUE ) { DeleteFileA("chk.tmp"); return true; } else MessageBox(NULL, "Failed to add file!", "Error!", MB_OK|MB_ICONEXCLAMATION); } else MessageBox(NULL, "Failed to open for updates!", "Error!", MB_OK|MB_ICONEXCLAMATION); DeleteFileA("chk.tmp"); } else MessageBox(NULL, "Failed to open file!\n\nThe file may be in use elsewhere.", "Error!", MB_OK|MB_ICONEXCLAMATION); } else // Is a chk file or unrecognized format, write out chk file { DeleteFileA(filePath); // Remove any existing files of the same name pFile = std::fopen(filePath, "wb"); WriteFile(pFile); std::fclose(pFile); return true; } } } return false; }
bool yaAcaAppClass::OnInit() { int i; App = this; printf ("yaACA2 Apollo ACA simulation, ver " VER(NVER) ", built " __DATE__ " " __TIME__ "\n"); printf ("Copyright 2009 by Ronald S. Burkey\n"); printf ("Refer to http://www.ibiblio.org/apollo/index.html for more information.\n"); Portnum = 19803; for (i = 1; i < argc; i++) { wxString Arg = argv[i]; wxString ArgStart = Arg.BeforeFirst ('='); wxString ArgEnd = Arg.AfterFirst ('='); if (ArgStart.IsSameAs (wxT ("--ip"))) { strcpy (NonDefaultHostname, ArgEnd.char_str ()); Hostname = NonDefaultHostname; } else if (ArgStart.IsSameAs (wxT ("--port"))) { long lPortnum; ArgEnd.ToLong (&lPortnum); Portnum = lPortnum; if (Portnum <= 0 || Portnum >= 0x10000) { printf ("The --port switch is out of range. Must be 1-64K.\n"); goto Help; } } else if (ArgStart.IsSameAs (wxT ("--delay"))) { long lj; ArgEnd.ToLong (&lj); StartupDelay = lj; } else if (ArgStart.IsSameAs (wxT ("--controller"))) { long lj; ArgEnd.ToLong (&lj); if (lj < 0 || lj > 1) { wxMessageBox (wxT ("Only --controller=0 and --controller=1 are allowed."), wxT ("Error"), wxICON_ERROR); goto Help; } else ControllerNumber = lj; } else { Help: printf ("USAGE:\n"); printf ("\tyaACA2 [OPTIONS]\n"); printf ("The available options are:\n"); printf ("--ip=Hostname\n"); printf ("\tThe yaACA2 program and the yaAGC Apollo Guidance Computer simulation\n"); printf ("\texist in a \"client/server\" relationship, in which the yaACA2 program\n"); printf ("\tneeds to be aware of the IP address or symbolic name of the host \n"); printf ("\tcomputer running the yaAGC program. By default, this is \"localhost\",\n"); printf ("\tmeaning that both yaACA2 and yaAGC are running on the same computer.\n"); printf ("--port=Portnumber\n"); printf ("\tBy default, yaACA2 attempts to connect to the yaAGC program using port\n"); printf ("\tnumber %d. However, if more than one instance of yaACA2 is being\n", Portnum); printf ("\trun, or if yaAGC has been configured to listen on different ports, then\n"); printf ("\tdifferent port settings for yaACA2 are needed. Note that by default,\n"); printf ("\tyaAGC listens for new connections on ports %d-%d.\n", 19697, 19697 + 10 - 1); printf ("--delay=N\n"); printf ("\t\"Start-up delay\", in ms. Defaults to %d. What the start-up\n", StartupDelay); printf ("\tdelay does is to prevent yaACA2 from attempting to communicate with\n"); printf ("\tyaAGC for a brief time after power-up. This option is really only\n"); printf ("\tuseful in Win32, to work around a problem with race-conditions at\n"); printf ("\tstart-up.\n"); printf ("--roll=...\n"); printf ("--pitch=...\n"); printf ("--yaw=...\n"); printf ("\tThese options are accepted for backward-compatibility with yaACA, the\n"); printf ("\tpredecessor to yaACA2, but are ignored.\n"); printf ("--controller=N\n"); printf ("\tIn case there are two joystick controllers attached, this allows\n"); printf ("\tselection of just one of them. The default is N=0, but N=1 is also\n"); printf ("\tallowed. If there are more than two attached, only the first two can\n"); printf ("\tbe accessed.\n"); exit (1); } } wxInitAllImageHandlers(); yaAcaFrame = new yaAcaFrameClass(NULL, wxID_ANY, wxEmptyString); SetTopWindow(yaAcaFrame); yaAcaFrame->Timer = new TimerClass (); yaAcaFrame->Timer->Initialization = 0; yaAcaFrame->Timer->Start (PULSE_INTERVAL); yaAcaFrame->Show(); return true; }
bool MapFile::OpenFile() { if ( filePath != nullptr ) { buffer chk("oMAP"); char* ext = strrchr(filePath, '.'); // Find the last occurrence of '.' if ( ext != nullptr ) { if ( strcmp(ext, ".scm") == 0 || strcmp(ext, ".scx") == 0 ) { HANDLE hMpq = MpqOpenArchiveForUpdate(filePath, MOAU_OPEN_EXISTING, 1000); if ( hMpq != NULL && hMpq != INVALID_HANDLE_VALUE ) { FileToBuffer(hMpq, "staredit\\scenario.chk", chk); MpqCloseUpdatedArchive(hMpq, 0); if ( chk.size() > 0 && ParseScenario(chk) ) { if ( VER().exists() ) { if ( VER().get<u16>(0) < 63 ) SaveType = 1; // Vanilla else if ( VER().get<u16>(0) < 205 ) SaveType = 2; // Hybrid else SaveType = 3; // Expansion } else if ( strcmp(ext, ".scx") == 0 ) SaveType = 3; // Expansion else if ( true ) // Could search for clues to map version here SaveType = 6; // Otherwise set to expansion to prevent data loss return true; } } else if ( GetLastError() == ERROR_FILE_NOT_FOUND ) CHKD_ERR("File Not Found"); else if ( GetLastError() == MPQ_ERROR_MPQ_INVALID ) CHKD_ERR("Invalid or corrupt MPQ file"); else CHKD_ERR("%d", GetLastError()); } else if ( strcmp(ext, ".chk") == 0 ) { if ( FileToBuffer(filePath, chk) ) { if ( ParseScenario(chk) ) { if ( VER().exists() ) { if ( VER().get<u16>(0) < 63 ) SaveType = 4; // Vanilla chk else if ( VER().get<u16>(0) < 205 ) SaveType = 5; // Hybrid chk else SaveType = 6; // Expansion chk } else if ( true ) // Could search for clues to map version here SaveType = 6; // Otherwise set to expansion to prevent data loss return true; } else CHKD_ERR("Parsing Failed!"); } else CHKD_ERR("Error Reading CHK File"); } } } return false; }
/* * LID table */ ltable_entry_struct logical_data_item_table_ul1[] = { #if defined (__UL1_PLATFORM__) { NVRAM_EF_UL1_RF_CUSTPACK_DATA_SELECT_LID, NVRAM_EF_UL1_RF_CUSTPACK_DATA_SELECT_TOTAL, NVRAM_EF_UL1_RF_CUSTPACK_DATA_SELECT_SIZE, NVRAM_CUSTPACK(COMMON_NVRAM_EF_UL1_RF_CUSTPACK_DATA_SELECT_DEFAULT), NVRAM_CATEGORY_USER| NVRAM_CATEGORY_CUSTPACK, NVRAM_ATTR_AVERAGE | NVRAM_ATTR_MULTI_DEFAULT, "MT2Q", VER(NVRAM_EF_UL1_RF_CUSTPACK_DATA_SELECT_LID) }, { NVRAM_EF_UL1_RF_CUSTOM_DATA_LID, NVRAM_EF_UL1_RF_CUSTOM_DATA_TOTAL, NVRAM_EF_UL1_RF_CUSTOM_DATA_SIZE, NVRAM_CUSTPACK(COMMON_NVRAM_EF_UL1_RF_CUSTOM_DATA_DEFAULT), NVRAM_CATEGORY_USER| NVRAM_CATEGORY_CUSTPACK, NVRAM_ATTR_AVERAGE | NVRAM_ATTR_MULTI_DEFAULT, "MT2R", VER(NVRAM_EF_UL1_RF_CUSTOM_DATA_LID) }, #endif /* #if defined (__UL1_PLATFORM__) */ #if (defined (__UL1_HS_PLATFORM__) || defined (__UL1_HS_PLUS_PLATFORM__))
unsigned char version_minor; /** * Is driver support forced by the ABI? */ unsigned char driver_support; }; /** * List of known GLX Extensions. * The last Y/N switch informs whether the support of this extension is always enabled. */ static const struct extension_info known_glx_extensions[] = { /* GLX_ARB_get_proc_address is implemented on the client. */ /* *INDENT-OFF* */ { GLX(ARB_context_flush_control), VER(0,0), N, }, { GLX(ARB_create_context), VER(0,0), N, }, { GLX(ARB_create_context_profile), VER(0,0), N, }, { GLX(ARB_create_context_robustness), VER(0,0), N, }, { GLX(ARB_fbconfig_float), VER(0,0), N, }, { GLX(ARB_framebuffer_sRGB), VER(0,0), N, }, { GLX(ARB_multisample), VER(1,4), Y, }, { GLX(EXT_create_context_es2_profile), VER(0,0), N, }, { GLX(EXT_framebuffer_sRGB), VER(0,0), N, }, { GLX(EXT_import_context), VER(0,0), Y, }, { GLX(EXT_texture_from_pixmap), VER(0,0), Y, }, { GLX(EXT_visual_info), VER(0,0), Y, }, { GLX(EXT_visual_rating), VER(0,0), Y, }, { GLX(MESA_copy_sub_buffer), VER(0,0), N, },
#include "libnvram.h" #include "inc/CFG_file_lid.h" #include "inc/CFG_module_file.h" #include "inc/CFG_module_default.h" #include "inc/CFG_file_info.h" #include "CFG_file_info_custom.h" #include "CFG_Dfo_File.h" #include "CFG_Dfo_Default.h" #include <stdio.h> #define MAX_FILENAMELEN 128; #define RESERVE_PATH "Reserved" #define RESERVE_VER "000" const TCFG_FILE g_akCFG_File[]= { //nvram version information { "/data/nvram/APCFG/APRDCL/FILE_VER", VER(AP_CFG_FILE_VER_INFO_LID), 4, CFG_FILE_VER_FILE_REC_TOTAL, DEFAULT_ZERO, 0, DataReset , NULL }, #ifdef MTK_COMBO_SUPPORT { "/data/nvram/APCFG/APRDEB/BT_Addr", VER(AP_CFG_RDEB_FILE_BT_ADDR_LID), CFG_FILE_BT_ADDR_REC_SIZE, CFG_FILE_BT_ADDR_REC_TOTAL, DEFAULT_ZERO, 0, DataReset , NULL}, #else { "/data/nvram/APCFG/APRDEB/BT_Addr", VER(AP_CFG_RDEB_FILE_BT_ADDR_LID), CFG_FILE_BT_ADDR_REC_SIZE, CFG_FILE_BT_ADDR_REC_TOTAL, SIGNLE_DEFUALT_REC, (char *)&stBtDefault, DataReset , NULL}, #endif #if 0 { "/data/nvram/APCFG/APRDEB/WIFI", VER(AP_CFG_RDEB_FILE_WIFI_LID), CFG_FILE_WIFI_REC_SIZE, CFG_FILE_WIFI_REC_TOTAL, SIGNLE_DEFUALT_REC, (char *)&stWifiCfgDefault, DataReset , NULL}, #endif { "/data/nvram/APCFG/APRDCL/AUXADC", VER(AP_CFG_RDCL_FILE_AUXADC_LID), CFG_FILE_AUXADC_REC_SIZE, CFG_FILE_AUXADC_REC_TOTAL, SIGNLE_DEFUALT_REC, (char *)&stADCDefualt, DataReset , NULL},
void Resource::saveOrLoad(Serializer &ser) { uint8_t loadedList[64]; if (ser._mode == Serializer::SM_SAVE) { memset(loadedList, 0, sizeof(loadedList)); uint8_t *p = loadedList; uint8_t *q = _memPtrStart; while (1) { MemEntry *it = _memList; MemEntry *me = 0; uint16_t num = _numMemList; while (num--) { if (it->state == MEMENTRY_STATE_LOADED && it->bufPtr == q) { me = it; } ++it; } if (me == 0) { break; } else { assert(p < loadedList + 64); *p++ = me - _memList; q += me->size; } } } Serializer::Entry entries[] = { SE_ARRAY(loadedList, 64, Serializer::SES_INT8, VER(1)), SE_INT(¤tPartId, Serializer::SES_INT16, VER(1)), SE_PTR(&_scriptBakPtr, VER(1)), SE_PTR(&_scriptCurPtr, VER(1)), SE_PTR(&_vidBakPtr, VER(1)), SE_PTR(&_vidCurPtr, VER(1)), SE_INT(&_useSegVideo2, Serializer::SES_BOOL, VER(1)), SE_PTR(&segPalettes, VER(1)), SE_PTR(&segBytecode, VER(1)), SE_PTR(&segCinematic, VER(1)), SE_PTR(&_segVideo2, VER(1)), SE_END() }; ser.saveOrLoadEntries(entries); if (ser._mode == Serializer::SM_LOAD) { uint8_t *p = loadedList; uint8_t *q = _memPtrStart; while (*p) { MemEntry *me = &_memList[*p++]; readBank(me, q); me->bufPtr = q; me->state = MEMENTRY_STATE_LOADED; q += me->size; } } }