Ticket #3060: aimanager.diff
File aimanager.diff, 2.5 KB (added by , 9 years ago) |
---|
-
source/simulation2/components/CCmpAIManager.cpp
558 558 { 559 559 JSContext* cx = m_ScriptInterface->GetContext(); 560 560 JSAutoRequest rq(cx); 561 561 562 serializer.NumberU32_Unbounded("num ais", (u32)m_Players.size()); 563 562 564 std::stringstream rngStream; 563 565 rngStream << m_RNG; 564 566 serializer.StringASCII("rng", rngStream.str(), 0, 32); … … 565 567 566 568 serializer.NumberU32_Unbounded("turn", m_TurnNum); 567 569 568 serializer.NumberU32_Unbounded("num ais", (u32)m_Players.size());569 570 570 serializer.Bool("useSharedScript", m_HasSharedComponent); 571 571 if (m_HasSharedComponent) 572 572 { … … 606 606 } 607 607 } 608 608 609 voidDeserialize(std::istream& stream)609 uint32_t PreDeserialize(std::istream& stream) 610 610 { 611 611 JSContext* cx = m_ScriptInterface->GetContext(); 612 612 JSAutoRequest rq(cx); 613 613 614 614 ENSURE(m_CommandsComputed); // deserializing while we're still actively computing would be bad 615 615 616 616 CStdDeserializer deserializer(*m_ScriptInterface, stream); 617 617 618 uint32_t numAis; 619 deserializer.NumberU32_Unbounded("num ais", numAis); 620 return numAis; 621 } 622 623 void Deserialize(std::istream& stream, uint32_t numAis) 624 { 625 JSContext* cx = m_ScriptInterface->GetContext(); 626 JSAutoRequest rq(cx); 627 628 ENSURE(m_CommandsComputed); // deserializing while we're still actively computing would be bad 629 630 CStdDeserializer deserializer(*m_ScriptInterface, stream); 631 618 632 m_PlayerMetadata.clear(); 619 633 m_Players.clear(); 620 634 … … 626 640 627 641 deserializer.NumberU32_Unbounded("turn", m_TurnNum); 628 642 629 uint32_t numAis;630 deserializer.NumberU32_Unbounded("num ais", numAis);631 632 643 deserializer.Bool("useSharedScript", m_HasSharedComponent); 633 TryLoadSharedComponent(false);634 644 if (m_HasSharedComponent) 635 645 { 646 TryLoadSharedComponent(false); 647 636 648 JS::RootedValue sharedData(cx); 637 649 JS::RootedValue tmpSharedAIObj(cx, m_SharedAIObj.get()); // TODO: Check if this temporary root can be removed after SpiderMonkey 31 638 650 deserializer.ScriptVal("sharedData", &sharedData); … … 853 865 { 854 866 Init(paramNode); 855 867 856 ForceLoadEntityTemplates(); 868 uint32_t numAis = m_Worker.PreDeserialize(deserialize.GetStream()); 869 if (numAis > 0) 870 ForceLoadEntityTemplates(); 857 871 858 m_Worker.Deserialize(deserialize.GetStream() );872 m_Worker.Deserialize(deserialize.GetStream(), numAis); 859 873 860 874 m_JustDeserialized = true; 861 875 }