This commit is contained in:
aozhiwei 2022-09-06 15:02:29 +08:00
parent 7577b16ca3
commit a234f2c2e5
5 changed files with 58 additions and 0 deletions

View File

@ -35,6 +35,15 @@ void Android::Initialize()
{ {
auto context = std::make_shared<BattleDataContext>(); auto context = std::make_shared<BattleDataContext>();
SetBattleContext(context); SetBattleContext(context);
context->ForceInit
(
App::Instance()->AllocTempHeroUniId(),
meta,
App::Instance()->AllocTempWeaponUniId(),
GetCurrWeapon()->meta,
0,
nullptr
);
} }
} }

View File

@ -675,3 +675,27 @@ void App::FreeIMMsgQueue()
} }
im_msg_mutex_->unlock(); im_msg_mutex_->unlock();
} }
long long App::AllocTempHeroUniId()
{
if (curr_uniid_ < 1000) {
curr_uniid_ = 1000;
}
if (curr_uniid_ > 100000000) {
curr_uniid_ = 1001;
}
++curr_uniid_;
return -curr_uniid_;
}
long long App::AllocTempWeaponUniId()
{
if (curr_uniid_ < 1000) {
curr_uniid_ = 1000;
}
if (curr_uniid_ > 100000000) {
curr_uniid_ = 1000;
}
++curr_uniid_;
return -curr_uniid_;
}

View File

@ -38,6 +38,8 @@ public:
bool HasFlag(int flag); bool HasFlag(int flag);
void SetFlag(int flag); void SetFlag(int flag);
void UnSetFlag(int flag); void UnSetFlag(int flag);
long long AllocTempHeroUniId();
long long AllocTempWeaponUniId();
private: private:
void QuickExecute(int delta_time); void QuickExecute(int delta_time);
@ -100,6 +102,8 @@ private:
std::map<long long, a8::XParams> context_hash_; std::map<long long, a8::XParams> context_hash_;
long long curr_uniid_ = 0;
public: public:
int msgnode_size_ = 0 ; int msgnode_size_ = 0 ;
int working_msgnode_size_ = 0; int working_msgnode_size_ = 0;

View File

@ -15,6 +15,8 @@
#include "obstacle.h" #include "obstacle.h"
#include "ability.h" #include "ability.h"
#include "entityfactory.h" #include "entityfactory.h"
#include "app.h"
Car::Car():Creature() Car::Car():Creature()
{ {
@ -54,6 +56,15 @@ void Car::Initialize()
{ {
auto context = std::make_shared<BattleDataContext>(); auto context = std::make_shared<BattleDataContext>();
SetBattleContext(context); SetBattleContext(context);
context->ForceInit
(
App::Instance()->AllocTempHeroUniId(),
hero_meta_,
App::Instance()->AllocTempWeaponUniId(),
GetCurrWeapon()->meta,
0,
nullptr
);
} }
} }

View File

@ -14,6 +14,7 @@
#include "bullet.h" #include "bullet.h"
#include "explosion.h" #include "explosion.h"
#include "roomobstacle.h" #include "roomobstacle.h"
#include "app.h"
Hero::Hero():Creature() Hero::Hero():Creature()
{ {
@ -51,6 +52,15 @@ void Hero::Initialize()
{ {
auto context = std::make_shared<BattleDataContext>(); auto context = std::make_shared<BattleDataContext>();
SetBattleContext(context); SetBattleContext(context);
context->ForceInit
(
App::Instance()->AllocTempHeroUniId(),
meta,
App::Instance()->AllocTempWeaponUniId(),
GetCurrWeapon()->meta,
0,
nullptr
);
} }
} }