Ticket #4053: autorequestfix_v2.patch
File autorequestfix_v2.patch, 8.3 KB (added by , 8 years ago) |
---|
-
source/gui/GUIManager.cpp
void CGUIManager::PopPageCB(shared_ptr<S 115 115 shared_ptr<ScriptInterface::StructuredClone> initDataClone = m_PageStack.back().initData; 116 116 PopPage(); 117 117 118 118 shared_ptr<ScriptInterface> scriptInterface = m_PageStack.back().gui->GetScriptInterface(); 119 119 JSContext* cx = scriptInterface->GetContext(); 120 JSAutoRequest rq(cx); 121 120 122 JS::RootedValue initDataVal(cx); 121 123 if (!initDataClone) 122 124 { 123 125 LOGERROR("Called PopPageCB when initData (which should contain the callback function name) isn't set!"); 124 126 return; -
source/network/NetTurnManager.cpp
void CNetTurnManager::AddCommand(int cli 300 300 debug_warn(L"Received command for invalid turn"); 301 301 return; 302 302 } 303 303 304 304 m_Simulation2.GetScriptInterface().FreezeObject(data, true); 305 m_QueuedCommands[turn - (m_CurrentTurn+1)][client].emplace_back(player, m_Simulation2.GetScriptInterface().GetContext(), data); 305 306 JSContext* cx = m_Simulation2.GetScriptInterface().GetContext(); 307 JSAutoRequest rq(cx); 308 309 m_QueuedCommands[turn - (m_CurrentTurn+1)][client].emplace_back(player, cx, data); 306 310 } 307 311 308 312 void CNetTurnManager::FinishedAllCommands(u32 turn, u32 turnLength) 309 313 { 310 314 NETTURN_LOG((L"FinishedAllCommands(%d, %d)\n", turn, turnLength)); … … void CNetReplayTurnManager::DoTurn(u32 t 564 568 { 565 569 debug_printf("Executing turn %u of %u\n", turn, m_FinalTurn); 566 570 567 571 m_TurnLength = m_ReplayTurnLengths[turn]; 568 572 573 JSContext* cx = m_Simulation2.GetScriptInterface().GetContext(); 574 JSAutoRequest rq(cx); 575 569 576 // Simulate commands for that turn 570 577 for (const std::pair<player_id_t, std::string>& p : m_ReplayCommands[turn]) 571 578 { 572 JS::RootedValue command( m_Simulation2.GetScriptInterface().GetContext());579 JS::RootedValue command(cx); 573 580 m_Simulation2.GetScriptInterface().ParseJSON(p.second, &command); 574 581 AddCommand(m_ClientId, p.first, command, m_CurrentTurn + 1); 575 582 } 576 583 577 584 if (turn == m_FinalTurn) -
source/ps/Game.cpp
bool CGame::StartVisualReplay(const std: 183 183 std::string type; 184 184 ENSURE((*m_ReplayStream >> type).good() && type == "start"); 185 185 186 186 std::string line; 187 187 std::getline(*m_ReplayStream, line); 188 JS::RootedValue attribs(scriptInterface.GetContext()); 188 189 JSContext* cx = scriptInterface.GetContext(); 190 JSAutoRequest rq(cx); 191 192 JS::RootedValue attribs(cx); 189 193 scriptInterface.ParseJSON(line, &attribs); 190 194 StartGame(&attribs, ""); 191 195 192 196 return true; 193 197 } -
source/ps/scripting/JSInterface_VFS.cpp
JS::Value JSI_VFS::BuildDirEntList(Scrip 89 89 if (!filterStr.empty()) 90 90 filter = filterStr.c_str(); 91 91 92 92 int flags = recurse ? vfs::DIR_RECURSIVE : 0; 93 93 94 JSContext* cx = pCxPrivate->pScriptInterface->GetContext(); 95 JSAutoRequest rq(cx); 96 94 97 // build array in the callback function 95 BuildDirEntListState state( pCxPrivate->pScriptInterface->GetContext());98 BuildDirEntListState state(cx); 96 99 vfs::ForEachFile(g_VFS, path, BuildDirEntListCB, (uintptr_t)&state, filter, flags); 97 100 98 101 return OBJECT_TO_JSVAL(state.filename_array); 99 102 } 100 103 -
source/simulation2/components/CCmpAIManager.cpp
public: 296 296 JS::HandleValue position, JS::HandleValue goal, pass_class_t passClass) 297 297 { 298 298 ENSURE(pCxPrivate->pCBData); 299 299 CAIWorker* self = static_cast<CAIWorker*> (pCxPrivate->pCBData); 300 300 JSContext* cx(self->m_ScriptInterface->GetContext()); 301 JSAutoRequest rq(cx); 301 302 302 303 CFixedVector2D pos, goalPos; 303 304 std::vector<CFixedVector2D> waypoints; 304 305 JS::RootedValue retVal(cx); 305 306 … … public: 325 326 static JS::Value GetConnectivityGrid(ScriptInterface::CxPrivate* pCxPrivate, pass_class_t passClass) 326 327 { 327 328 ENSURE(pCxPrivate->pCBData); 328 329 CAIWorker* self = static_cast<CAIWorker*> (pCxPrivate->pCBData); 329 330 JSContext* cx(self->m_ScriptInterface->GetContext()); 331 JSAutoRequest rq(cx); 330 332 331 333 JS::RootedValue retVal(cx); 332 334 self->m_ScriptInterface->ToJSVal<Grid<u16> >(cx, &retVal, self->m_LongPathfinder.GetConnectivityGrid(passClass)); 333 335 return retVal; 334 336 } … … public: 519 521 { 520 522 ENSURE(m_CommandsComputed); 521 523 522 524 m_GameState = gameState; 523 525 JSContext* cx = m_ScriptInterface->GetContext(); 526 JSAutoRequest rq(cx); 524 527 525 528 if (dirtinessInformations.dirty) 526 529 { 527 530 m_PassabilityMap = passabilityMap; 528 531 if (dirtinessInformations.globallyDirty) … … public: 768 771 void RegisterSerializablePrototype(std::wstring name, JS::HandleValue proto) 769 772 { 770 773 // Require unique prototype and name (for reverse lookup) 771 774 // TODO: this is yucky - see comment in Deserialize() 772 775 ENSURE(proto.isObject() && "A serializable prototype has to be an object!"); 773 JS::RootedObject obj(m_ScriptInterface->GetContext(), &proto.toObject()); 776 777 JSContext* cx = m_ScriptInterface->GetContext(); 778 JSAutoRequest rq(cx); 779 780 JS::RootedObject obj(cx, &proto.toObject()); 774 781 if (m_SerializablePrototypes->has(obj) || m_DeserializablePrototypes.find(name) != m_DeserializablePrototypes.end()) 775 782 { 776 783 LOGERROR("RegisterSerializablePrototype called with same prototype multiple times: p=%p n='%s'", (void *)obj.get(), utf8_from_wstring(name)); 777 784 return; 778 785 } 779 m_SerializablePrototypes->add( m_ScriptInterface->GetContext(), obj, name);786 m_SerializablePrototypes->add(cx, obj, name); 780 787 m_DeserializablePrototypes[name] = JS::Heap<JSObject*>(obj); 781 788 } 782 789 783 790 private: 784 791 static void Trace(JSTracer *trc, void *data) -
source/simulation2/components/CCmpCommandQueue.cpp
public: 80 80 } 81 81 82 82 virtual void PushLocalCommand(player_id_t player, JS::HandleValue cmd) 83 83 { 84 84 JSContext* cx = GetSimContext().GetScriptInterface().GetContext(); 85 JSAutoRequest rq(cx); 86 85 87 m_LocalQueue.emplace_back(SimulationCommand(player, cx, cmd)); 86 88 } 87 89 88 90 virtual void PostNetworkCommand(JS::HandleValue cmd1) 89 91 { -
source/simulation2/serialization/BinarySerializer.cpp
u32 CBinarySerializerScriptImpl::GetScri 436 436 // If it was already there, return the tag 437 437 u32 tag; 438 438 if (m_ScriptBackrefs.find(obj, tag)) 439 439 return tag; 440 440 441 m_ScriptBackrefs.add(m_ScriptInterface.GetContext(), obj, m_ScriptBackrefsNext); 441 JSContext* cx = m_ScriptInterface.GetContext(); 442 JSAutoRequest rq(cx); 443 444 m_ScriptBackrefs.add(cx, obj, m_ScriptBackrefsNext); 442 445 443 446 m_ScriptBackrefsNext++; 444 447 // Return a non-tag number so callers know they need to serialize the object 445 448 return 0; 446 449 } -
source/simulation2/serialization/StdDeserializer.cpp
void CStdDeserializer::ScriptString(cons 464 464 465 465 #if BYTE_ORDER != LITTLE_ENDIAN 466 466 #error TODO: probably need to convert JS strings from little-endian 467 467 #endif 468 468 469 out.set(JS_NewUCStringCopyN(m_ScriptInterface.GetContext(), (const char16_t*)str.data(), str.length())); 469 JSContext* cx = m_ScriptInterface.GetContext(); 470 JSAutoRequest rq(cx); 471 472 out.set(JS_NewUCStringCopyN(cx, (const char16_t*)str.data(), str.length())); 470 473 if (!out) 471 474 throw PSERROR_Deserialize_ScriptError("JS_NewUCStringCopyN failed"); 472 475 } 473 476 474 477 void CStdDeserializer::ScriptVal(const char* name, JS::MutableHandleValue out)