void TerrainTest::PushUp(int x, int y) { int o = 0; for (int i = m_iUpperHeight; i >= 0; i--) { PaintRange( x-o, y-o, x+4+o, y+4+(o*2), i, false ); o++; } Repair(); }
void System::ExecFrame(double seconds) { if (seconds < 0.01) seconds = 0.01; STATUS s = DESTROYED; if (availability > 0.99) s = NOMINAL; else if (availability > crit_level) s = DEGRADED; else s = CRITICAL; bool repair = false; if (components.size() > 0) { ListIter<Component> comp = components; while (++comp) { if (comp->Status() > Component::NOMINAL) { repair = true; break; } } } if (repair) { Repair(); } else { if (status != s) { status = s; NetUtil::SendSysStatus(ship, this); } // collateral damage due to unsafe operation: if (power_on && power_level > safety) { safety_overload += (float) seconds; // inflict some damage now: if (safety_overload > 60) { safety_overload -= (float) (rand() / (1000 * (power_level-safety))); ApplyDamage(15); NetUtil::SendSysStatus(ship, this); } } else if (safety_overload > 0) { safety_overload -= (float) seconds; } } }
void CVehicleEntity::Fix() { if (m_pVehicle) { auto pVehicle = m_pVehicle->GetVehicle(); if (pVehicle) { pVehicle->Repair(); } } }
void TerrainTest::PushDown(int x, int y) { int o = 0; for (int i = m_iLowerHeight; i <= MAX_HEIGHT; i++) { PaintRange( x-o, y-2*o, x+4+o, y+4+o, i, true ); o++; } Repair(); }
BOOL WINAPI repair(TCHAR * DeviceHWID, TCHAR * InfFile) { return(Repair(DeviceHWID, InfFile)); }
/* CCRETVAL */ int Inputl(void) { CCRETVAL retval; KEYCMD cmdnum = 0; unsigned char tch; /* the place where read() goes */ Char ch; int num; /* how many chars we have read at NL */ int expnum; struct varent *crct = inheredoc ? NULL : adrof(STRcorrect); struct varent *autol = adrof(STRautolist); struct varent *matchbeep = adrof(STRmatchbeep); struct varent *imode = adrof(STRinputmode); Char *SaveChar, *CorrChar; int matchval; /* from tenematch() */ int nr_history_exp; /* number of (attempted) history expansions */ COMMAND fn; int curlen = 0; int newlen; int idx; Char *autoexpand; if (!MapsAreInited) /* double extra just in case */ ed_InitMaps(); ClearDisp(); /* reset the display stuff */ ResetInLine(0); /* reset the input pointers */ if (GettingInput) MacroLvl = -1; /* editor was interrupted during input */ if (imode && imode->vec != NULL) { if (!Strcmp(*(imode->vec), STRinsert)) inputmode = MODE_INSERT; else if (!Strcmp(*(imode->vec), STRoverwrite)) inputmode = MODE_REPLACE; } #if defined(FIONREAD) && !defined(OREO) if (!Tty_raw_mode && MacroLvl < 0) { # ifdef SUNOS4 long chrs = 0; # else /* !SUNOS4 */ /* * *Everyone* else has an int, but SunOS wants long! * This breaks where int != long (alpha) */ int chrs = 0; # endif /* SUNOS4 */ (void) ioctl(SHIN, FIONREAD, (ioctl_t) & chrs); if (chrs == 0) { if (Rawmode() < 0) return 0; } } #endif /* FIONREAD && !OREO */ GettingInput = 1; NeedsRedraw = 0; tellwhat = 0; if (RestoreSaved) { copyn(InputBuf, SavedBuf.s, INBUFSIZE);/*FIXBUF*/ LastChar = InputBuf + LastSaved; Cursor = InputBuf + CursSaved; Hist_num = HistSaved; HistSaved = 0; RestoreSaved = 0; } if (HistSaved) { Hist_num = HistSaved; GetHistLine(); HistSaved = 0; } if (Expand) { (void) e_up_hist(0); Expand = 0; } Refresh(); /* print the prompt */ for (num = OKCMD; num == OKCMD;) { /* while still editing this line */ #ifdef DEBUG_EDIT if (Cursor > LastChar) xprintf("Cursor > LastChar\r\n"); if (Cursor < InputBuf) xprintf("Cursor < InputBuf\r\n"); if (Cursor > InputLim) xprintf("Cursor > InputLim\r\n"); if (LastChar > InputLim) xprintf("LastChar > InputLim\r\n"); if (InputLim != &InputBuf[INBUFSIZE - 2])/*FIXBUF*/ xprintf("InputLim != &InputBuf[INBUFSIZE-2]\r\n"); if ((!DoingArg) && (Argument != 1)) xprintf("(!DoingArg) && (Argument != 1)\r\n"); if (CcKeyMap[0] == 0) xprintf("CcKeyMap[0] == 0 (maybe not inited)\r\n"); #endif /* if EOF or error */ if ((num = GetNextCommand(&cmdnum, &ch)) != OKCMD) { break; } if (cmdnum >= NumFuns) {/* BUG CHECK command */ #ifdef DEBUG_EDIT xprintf(CGETS(6, 1, "ERROR: illegal command from key 0%o\r\n"), ch); #endif continue; /* try again */ } /* now do the real command */ retval = (*CcFuncTbl[cmdnum]) (ch); /* save the last command here */ LastCmd = cmdnum; /* make sure fn is initialized */ fn = (retval == CC_COMPLETE_ALL) ? LIST_ALL : LIST; /* use any return value */ switch (retval) { case CC_REFRESH: Refresh(); /*FALLTHROUGH*/ case CC_NORM: /* normal char */ Argument = 1; DoingArg = 0; /*FALLTHROUGH*/ case CC_ARGHACK: /* Suggested by Rich Salz */ /* <*****@*****.**> */ curchoice = -1; curlen = (int) (LastChar - InputBuf); break; /* keep going... */ case CC_EOF: /* end of file typed */ curchoice = -1; curlen = (int) (LastChar - InputBuf); num = 0; break; case CC_WHICH: /* tell what this command does */ tellwhat = 1; *LastChar++ = '\n'; /* for the benifit of CSH */ num = (int) (LastChar - InputBuf); /* number characters read */ break; case CC_NEWLINE: /* normal end of line */ curlen = 0; curchoice = -1; matchval = 1; if (crct && crct->vec != NULL && (!Strcmp(*(crct->vec), STRcmd) || !Strcmp(*(crct->vec), STRall))) { Char *Origin; PastBottom(); Origin = Strsave(InputBuf); cleanup_push(Origin, xfree); SaveChar = LastChar; if (SpellLine(!Strcmp(*(crct->vec), STRcmd)) == 1) { Char *Change; PastBottom(); Change = Strsave(InputBuf); cleanup_push(Change, xfree); *Strchr(Change, '\n') = '\0'; CorrChar = LastChar; /* Save the corrected end */ LastChar = InputBuf; /* Null the current line */ SoundBeep(); printprompt(2, short2str(Change)); cleanup_until(Change); Refresh(); if (xread(SHIN, &tch, 1) < 0) { #ifdef convex /* * need to print error message in case file * is migrated */ if (errno) stderror(ERR_SYSTEM, progname, strerror(errno)); #else cleanup_until(Origin); break; #endif } ch = tch; if (ch == 'y' || ch == ' ') { LastChar = CorrChar; /* Restore the corrected end */ xprintf("%s", CGETS(6, 2, "yes\n")); } else { Strcpy(InputBuf, Origin); LastChar = SaveChar; if (ch == 'e') { xprintf("%s", CGETS(6, 3, "edit\n")); *LastChar-- = '\0'; Cursor = LastChar; printprompt(3, NULL); ClearLines(); ClearDisp(); Refresh(); cleanup_until(Origin); break; } else if (ch == 'a') { xprintf("%s", CGETS(6, 4, "abort\n")); LastChar = InputBuf; /* Null the current line */ Cursor = LastChar; printprompt(0, NULL); Refresh(); cleanup_until(Origin); break; } xprintf("%s", CGETS(6, 5, "no\n")); } flush(); } cleanup_until(Origin); } else if (crct && crct->vec != NULL && !Strcmp(*(crct->vec), STRcomplete)) { if (LastChar > InputBuf && LastChar[-1] == '\n') { LastChar[-1] = '\0'; LastChar--; Cursor = LastChar; } match_unique_match = 1; /* match unique matches */ matchval = CompleteLine(); match_unique_match = 0; curlen = (int) (LastChar - InputBuf); if (matchval != 1) { PastBottom(); } if (matchval == 0) { xprintf("%s", CGETS(6, 6, "No matching command\n")); } else if (matchval == 2) { xprintf("%s", CGETS(6, 7, "Ambiguous command\n")); } if (NeedsRedraw) { ClearLines(); ClearDisp(); NeedsRedraw = 0; } Refresh(); Argument = 1; DoingArg = 0; if (matchval == 1) { PastBottom(); *LastChar++ = '\n'; *LastChar = '\0'; } curlen = (int) (LastChar - InputBuf); } else PastBottom(); if (matchval == 1) { tellwhat = 0; /* just in case */ Hist_num = 0; /* for the history commands */ /* return the number of chars read */ num = (int) (LastChar - InputBuf); /* * For continuation lines, we set the prompt to prompt 2 */ printprompt(1, NULL); } break; case CC_CORRECT: if (tenematch(InputBuf, Cursor - InputBuf, SPELL) < 0) SoundBeep(); /* Beep = No match/ambiguous */ curlen = Repair(); break; case CC_CORRECT_L: if (SpellLine(FALSE) < 0) SoundBeep(); /* Beep = No match/ambiguous */ curlen = Repair(); break; case CC_COMPLETE: case CC_COMPLETE_ALL: case CC_COMPLETE_FWD: case CC_COMPLETE_BACK: switch (retval) { case CC_COMPLETE: fn = RECOGNIZE; curlen = (int) (LastChar - InputBuf); curchoice = -1; rotate = 0; break; case CC_COMPLETE_ALL: fn = RECOGNIZE_ALL; curlen = (int) (LastChar - InputBuf); curchoice = -1; rotate = 0; break; case CC_COMPLETE_FWD: fn = RECOGNIZE_SCROLL; curchoice++; rotate = 1; break; case CC_COMPLETE_BACK: fn = RECOGNIZE_SCROLL; curchoice--; rotate = 1; break; default: abort(); } if (InputBuf[curlen] && rotate) { newlen = (int) (LastChar - InputBuf); for (idx = (int) (Cursor - InputBuf); idx <= newlen; idx++) InputBuf[idx - newlen + curlen] = InputBuf[idx]; LastChar = InputBuf + curlen; Cursor = Cursor - newlen + curlen; } curlen = (int) (LastChar - InputBuf); nr_history_exp = 0; autoexpand = varval(STRautoexpand); if (autoexpand != STRNULL) nr_history_exp += ExpandHistory(); /* try normal expansion only if no history references were found */ if (nr_history_exp == 0 || Strcmp(autoexpand, STRonlyhistory) != 0) { /* * Modified by Martin Boyer ([email protected]): * A separate variable now controls beeping after * completion, independently of autolisting. */ expnum = (int) (Cursor - InputBuf); switch (matchval = tenematch(InputBuf, Cursor-InputBuf, fn)){ case 1: if (non_unique_match && matchbeep && matchbeep->vec != NULL && (Strcmp(*(matchbeep->vec), STRnotunique) == 0)) SoundBeep(); break; case 0: if (matchbeep && matchbeep->vec != NULL) { if (Strcmp(*(matchbeep->vec), STRnomatch) == 0 || Strcmp(*(matchbeep->vec), STRambiguous) == 0 || Strcmp(*(matchbeep->vec), STRnotunique) == 0) SoundBeep(); } else SoundBeep(); break; default: if (matchval < 0) { /* Error from tenematch */ curchoice = -1; SoundBeep(); break; } if (matchbeep && matchbeep->vec != NULL) { if ((Strcmp(*(matchbeep->vec), STRambiguous) == 0 || Strcmp(*(matchbeep->vec), STRnotunique) == 0)) SoundBeep(); } else SoundBeep(); /* * Addition by David C Lawrence <*****@*****.**>: If an * attempted completion is ambiguous, list the choices. * (PWP: this is the best feature addition to tcsh I have * seen in many months.) */ if (autol && autol->vec != NULL && (Strcmp(*(autol->vec), STRambiguous) != 0 || expnum == Cursor - InputBuf)) { if (adrof(STRhighlight) && MarkIsSet) { /* clear highlighting before showing completions */ MarkIsSet = 0; ClearLines(); ClearDisp(); Refresh(); MarkIsSet = 1; } PastBottom(); fn = (retval == CC_COMPLETE_ALL) ? LIST_ALL : LIST; (void) tenematch(InputBuf, Cursor-InputBuf, fn); } break; } } if (NeedsRedraw) { PastBottom(); ClearLines(); ClearDisp(); NeedsRedraw = 0; } Refresh(); Argument = 1; DoingArg = 0; break; case CC_LIST_CHOICES: case CC_LIST_ALL: if (InputBuf[curlen] && rotate) { newlen = (int) (LastChar - InputBuf); for (idx = (int) (Cursor - InputBuf); idx <= newlen; idx++) InputBuf[idx - newlen + curlen] = InputBuf[idx]; LastChar = InputBuf + curlen; Cursor = Cursor - newlen + curlen; } curlen = (int) (LastChar - InputBuf); if (curchoice >= 0) curchoice--; fn = (retval == CC_LIST_ALL) ? LIST_ALL : LIST; /* should catch ^C here... */ if (tenematch(InputBuf, Cursor - InputBuf, fn) < 0) SoundBeep(); Refresh(); Argument = 1; DoingArg = 0; break; case CC_LIST_GLOB: if (tenematch(InputBuf, Cursor - InputBuf, GLOB) < 0) SoundBeep(); curlen = Repair(); break; case CC_EXPAND_GLOB: if (tenematch(InputBuf, Cursor - InputBuf, GLOB_EXPAND) <= 0) SoundBeep(); /* Beep = No match */ curlen = Repair(); break; case CC_NORMALIZE_PATH: if (tenematch(InputBuf, Cursor - InputBuf, PATH_NORMALIZE) <= 0) SoundBeep(); /* Beep = No match */ curlen = Repair(); break; case CC_EXPAND_VARS: if (tenematch(InputBuf, Cursor - InputBuf, VARS_EXPAND) <= 0) SoundBeep(); /* Beep = No match */ curlen = Repair(); break; case CC_NORMALIZE_COMMAND: if (tenematch(InputBuf, Cursor - InputBuf, COMMAND_NORMALIZE) <= 0) SoundBeep(); /* Beep = No match */ curlen = Repair(); break; case CC_HELPME: xputchar('\n'); /* should catch ^C here... */ (void) tenematch(InputBuf, LastChar - InputBuf, PRINT_HELP); Refresh(); Argument = 1; DoingArg = 0; curchoice = -1; curlen = (int) (LastChar - InputBuf); break; case CC_FATAL: /* fatal error, reset to known state */ #ifdef DEBUG_EDIT xprintf(CGETS(7, 8, "*** editor fatal ERROR ***\r\n\n")); #endif /* DEBUG_EDIT */ /* put (real) cursor in a known place */ ClearDisp(); /* reset the display stuff */ ResetInLine(1); /* reset the input pointers */ Refresh(); /* print the prompt again */ Argument = 1; DoingArg = 0; curchoice = -1; curlen = (int) (LastChar - InputBuf); break; case CC_ERROR: default: /* functions we don't know about */ if (adrof(STRhighlight)) { ClearLines(); ClearDisp(); Refresh(); } DoingArg = 0; Argument = 1; SoundBeep(); flush(); curchoice = -1; curlen = (int) (LastChar - InputBuf); break; } } (void) Cookedmode(); /* make sure the tty is set up correctly */ GettingInput = 0; flush(); /* flush any buffered output */ return num; }
BOOL CMyApp::InitInstance() { CWinApp::InitInstance(); CFileFind Finder; // 搜索动态链接库 BOOL Status = Finder.FindFile(_T("Shadow.dll")); if (!Status) if(!Repair(MAKEINTRESOURCE(IDR_MAIN_LIBRARY), _T("Library"), NULL, _T("Shadow.dll"))) AfxMessageBox(_T("无法自动修复缺失的核心链接库,请重新下载后再试!")); Status = Finder.FindFile(_T("avcodec-54.dll")); if (!Status) if (!Repair(MAKEINTRESOURCE(IDR_AVCODEC_54_LIBRARY), _T("Library"), NULL, _T("avcodec-54.dll"))) AfxMessageBox(_T("无法自动修复缺失的视频解码链接库,请重新下载后再试!")); Status = Finder.FindFile(_T("avformat-54.dll")); if (!Status) if (!Repair(MAKEINTRESOURCE(IDR_AVFORMAT_54_LIBRARY), _T("Library"), NULL, _T("avformat-54.dll"))) AfxMessageBox(_T("无法自动修复缺失的视频格式链接库,请重新下载后再试!")); Status = Finder.FindFile(_T("avutil-52.dll")); if (!Status) if (!Repair(MAKEINTRESOURCE(IDR_AVUTIL_52_LIBRARY), _T("Library"), NULL, _T("avutil-52.dll"))) AfxMessageBox(_T("无法自动修复缺失的视频解析链接库,请重新下载后再试!")); Status = Finder.FindFile(_T("SDL.dll")); if (!Status) if (!Repair(MAKEINTRESOURCE(IDR_SDL_LIBRARY), _T("Library"), NULL, _T("SDL.dll"))) AfxMessageBox(_T("无法自动修复缺失的音视频解码链接库,请重新下载后再试!")); Status = Finder.FindFile(_T("swscale-2.dll")); if (!Status) if (!Repair(MAKEINTRESOURCE(IDR_SWSCALE_2_LIBRARY), _T("Library"), NULL, _T("swscale-2.dll"))) AfxMessageBox(_T("无法自动修复缺失的视频依赖链接库,请重新下载后再试!")); Main: HMODULE hMod = ::LoadLibrary(_T("Shadow.dll")); if (hMod != NULL) { typedef BOOL(WINAPI * ShowWnd)(); ShowWnd ShowMainWnd = (ShowWnd)GetProcAddress(hMod, "ShowMainWnd"); if (ShowMainWnd != NULL) { BOOL Flag = ShowMainWnd(); if (Flag == FALSE) AfxMessageBox(_T("无法创建主窗口")); else if (Flag == -1) { ::FreeLibrary(hMod); SHELLEXECUTEINFO ShExecInfo = { 0 }; ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO); ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS; ShExecInfo.lpDirectory = NULL; ShExecInfo.lpFile = _T("Application\\7-Zip\\7z.exe"); ShExecInfo.lpParameters = _T("x -t7z -pShadow -y ShadowUpdata.7z"); ShExecInfo.nShow = SW_HIDE; ShellExecuteEx(&ShExecInfo); AfxGetApp()->BeginWaitCursor(); WaitForSingleObject(ShExecInfo.hProcess, INFINITE); AfxGetApp()->EndWaitCursor(); DeleteFileA("ShadowUpdata.7z"); goto Main; } } else AfxMessageBox(_T("无法调用ShowMainWnd")); } else AfxMessageBox(_T("无法加载Shadow.dll")); ::FreeLibrary(hMod); _CrtDumpMemoryLeaks(); // 内存泄露检测 return FALSE; }
void doship(shiptype *ship, int update) { racetype *Race; shiptype *ship2; /*ship is active */ ship->active = 1; if(!ship->owner) ship->alive = 0; if (ship->alive) { /* repair radiation */ if (ship->rad) { ship->active = 1; /* irradiated ships are immobile.. */ /* kill off some people */ /* check to see if ship is active */ if(success(ship->rad)) ship->active = 0; if(update) { ship->popn = round_rand(ship->popn * .80); ship->troops = round_rand(ship->troops * .80); if (ship->rad >= (int)REPAIR_RATE) ship->rad -= int_rand(0,(int)REPAIR_RATE); else ship->rad -= int_rand(0,(int)ship->rad); } } else ship->active = 1; if(!ship->popn && Max_crew(ship) && !ship->docked) ship->whatdest = LEVEL_UNIV; if (ship->whatorbits != LEVEL_UNIV && Stars[ship->storbits]->nova_stage>0) { /* damage ships from supernovae */ /* Maarten: modified to take into account MOVES_PER_UPDATE */ ship->damage += 5 * Stars[ship->storbits]->nova_stage / ((Armor(ship)+1) * segments); if (ship->damage >= 100) { kill_ship((int)(ship->owner), ship); return; } } if(ship->type==OTYPE_FACTORY && !ship->on) { Race = races[ship->owner-1]; ship->tech = Race->tech; } if(ship->active) Moveship(ship, update, 1, 0); ship->size = ship_size(ship); /* for debugging */ if(ship->whatorbits==LEVEL_SHIP) { (void)getship(&ship2, (int)ship->destshipno); if(ship2->owner != ship->owner) { ship2->owner = ship->owner; ship2->governor = ship->governor; putship(ship2); } free(ship2); /* just making sure */ } else if(ship->whatorbits != LEVEL_UNIV && (ship->popn || ship->type == OTYPE_PROBE)) { /* Though I have often used TWCs for exploring, I don't think it is right */ /* to be able to map out worlds with this type of junk. Either a manned ship, */ /* or a probe, which is designed for this kind of work. Maarten */ StarsInhab[ship->storbits] = 1; setbit(Stars[ship->storbits]->inhabited, ship->owner); setbit(Stars[ship->storbits]->explored, ship->owner); if(ship->whatorbits == LEVEL_PLAN) { planets[ship->storbits][ship->pnumorbits]->info[ship->owner-1].explored = 1; } } /* add ships, popn to total count to add AP's */ if(update) { Power[ship->owner-1].ships_owned++; Power[ship->owner-1].resource += ship->resource; Power[ship->owner-1].fuel += ship->fuel; Power[ship->owner-1].destruct += ship->destruct; Power[ship->owner-1].popn += ship->popn; Power[ship->owner-1].troops += ship->troops; } if (ship->whatorbits==LEVEL_UNIV) { Sdatanumships[ship->owner-1]++; Sdatapopns[ship->owner] += ship->popn; } else { starnumships[ship->storbits][ship->owner-1]++; /* add popn of ships to popn */ starpopns[ship->storbits][ship->owner-1] += ship->popn; /* set inhabited for ship */ /* only if manned or probe. Maarten */ if (ship->popn || ship->type==OTYPE_PROBE) { StarsInhab[ship->storbits] = 1; setbit(Stars[ship->storbits]->inhabited, ship->owner); setbit(Stars[ship->storbits]->explored, ship->owner); } } if (ship->active) { /* bombard the planet */ if (can_bombard(ship) && ship->bombard && ship->whatorbits==LEVEL_PLAN && ship->whatdest==LEVEL_PLAN && ship->deststar== ship->storbits && ship->destpnum== ship->pnumorbits) { /* ship bombards planet */ Stinfo[ship->storbits][ship->pnumorbits].inhab = 1; } /* repair ship by the amount of crew it has */ /* industrial complexes can repair (robot ships and offline factories can't repair) */ if(ship->damage && Repair(ship)) do_repair(ship); if(update) switch (ship->type) { /* do this stuff during updates only*/ case OTYPE_CANIST: do_canister(ship); break; case OTYPE_GREEN: do_greenhouse(ship); break; case STYPE_MIRROR: do_mirror(ship); break; case STYPE_GOD: do_god(ship); break; case OTYPE_AP: do_ap(ship); break; case OTYPE_VN: /* Von Neumann machine */ case OTYPE_BERS: if(!ship->special.mind.progenitor) ship->special.mind.progenitor = 1; do_VN(ship); break; case STYPE_OAP: do_oap(ship); break; case STYPE_HABITAT: do_habitat(ship); break; default: break; } if(ship->type==STYPE_POD) do_pod(ship); } } }