JBoolean CMLink::Send ( CMCommand* command ) { if (command->GetState() != CMCommand::kUnassigned) { assert( command->GetTransactionID() != 0 ); return kJFalse; } else { command->SetTransactionID(GetNextTransactionID()); if (command->IsBackground()) { itsBackgroundQ->Append(command); } else { itsForegroundQ->Append(command); } RunNextCommand(); return kJTrue; } }
void Credits::Tick() { /*debug("scroll_y: %d", scroll_y>>CSF); debug("spawn_y: %d", spawn_y); debug("scr_spawn_y: %d", SCREEN_Y(spawn_y)); debug("trigger: %d", SCREEN_HEIGHT+MARGIN); debug("");*/ /*debug("imgno: %d", bigimage.imgno); debug("state: %d", bigimage.state); debug("imagex: %d", bigimage.imagex);*/ if (roll_running || SCREEN_Y(spawn_y) >= (SCREEN_HEIGHT + 8)) { scroll_y += 0x100; } while(roll_running && SCREEN_Y(spawn_y) < (SCREEN_HEIGHT + MARGIN)) { RunNextCommand(); } if (player) { player->hide = true; player->dead = true; // should pretty much completely disable HandlePlayer() } game_tick_normal(); bigimage.Draw(); Draw(); }
void XDLink::ReceiveMessageFromDebugger() { itsLink->StopTimer(); JString data; const JBoolean ok = itsLink->GetNextMessage(&data); assert( ok ); if (data.IsEmpty() || data.GetFirstCharacter() != '<') { return; } Broadcast(DebugOutput(data, kOutputType)); if (itsInitFinishedFlag) { if (!itsProgramIsStoppedFlag) { itsProgramIsStoppedFlag = kJTrue; Broadcast(ProgramStopped(CMLocation("", 1))); } itsDebuggerBusyFlag = kJFalse; Broadcast(DebuggerReadyForInput()); } xmlDoc* doc = xmlReadMemory(data.GetCString(), data.GetLength(), NULL, NULL, XML_PARSE_NOCDATA); if (doc != NULL) { xmlNode* root = xmlDocGetRootElement(doc); if (root != NULL && strcmp((char*) root->name, "init") == 0) { itsIDEKey = JGetXMLNodeAttr(root, "idekey"); const JString uri = JGetXMLNodeAttr(root, "fileuri"); const JCharacter* map[] = { "idekey", itsIDEKey, "uri", uri }; JString msg = JGetString("ConnectionInfo::XDLink", map, sizeof(map)); Broadcast(UserOutput(msg, kJFalse)); Send("feature_set -n show_hidden -v 1"); Send("step_into"); JString programName; GetProgram(&programName); Broadcast(AttachedToProcess()); Broadcast(SymbolsLoaded(JI2B(uri == itsScriptURI), programName)); itsInitFinishedFlag = kJTrue; itsScriptURI = uri; } else if (root != NULL && strcmp((char*) root->name, "response") == 0) { const JString status = JGetXMLNodeAttr(root, "status"); const JString reason = JGetXMLNodeAttr(root, "reason"); if (status == "break" && reason == "error" && root->children != NULL && root->children->children != NULL && strcmp((char*) root->children->name, "error") == 0 && root->children->children->type == XML_TEXT_NODE) { JString msg = (char*) root->children->children->content; const JString encoding = JGetXMLNodeAttr(root->children, "encoding"); if (encoding == "base64") { msg.DecodeBase64(&msg); } msg += "\n"; Broadcast(UserOutput(msg, kJTrue)); } const JString idStr = JGetXMLNodeAttr(root, "transaction_id"); JUInt id; if (idStr.ConvertToUInt(&id)) { HandleCommandRunning(id); } CMCommand* cmd; if (GetRunningCommand(&cmd)) { itsParsedDataRoot = root; cmd->Finished(JI2B( root->children == NULL || strcmp((char*) root->children->name, "error") != 0)); itsParsedDataRoot = NULL; SetRunningCommand(NULL); if (!HasForegroundCommands()) { RunNextCommand(); } } if (status == "stopping" || status == "stopped") { CancelAllCommands(); XDCloseSocketTask* task = new XDCloseSocketTask(itsLink); assert( task != NULL ); task->Go(); } } xmlFreeDoc(doc); } }