Skip to content

Commit

Permalink
・Draw処理の常駐タスク関連のバグを修正
Browse files Browse the repository at this point in the history
・ローカル変数扱いの参照を除去
・微修正
  • Loading branch information
At-sushi committed Mar 30, 2017
1 parent 71cb013 commit 553b2ef
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 21 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# GTFramework
Goluah Task Framework ver0.99c
Goluah Task Framework ver0.99d

「Goluah!」から流用したゲーム開発向け汎用タスクシステム

Expand Down
21 changes: 7 additions & 14 deletions src/system/task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,19 +273,18 @@ namespace GTF
{
TaskList::iterator i, ied;
shared_ptr<CExclusiveTaskBase> pex;
auto& drawList = ex_stack.top().drawList;

//排他タスクを取得
assert(ex_stack.size() != 0);
if (ex_stack.top().value && ex_stack.top().value->GetDrawPriority() >= 0){
pex = ex_stack.top().value;
}

auto iv = drawList.begin();
auto iedv = pex ? drawList.upper_bound(pex->GetDrawPriority()) : drawList.end();
auto iv = ex_stack.top().drawList.begin();
auto iedv = pex ? ex_stack.top().drawList.upper_bound(pex->GetDrawPriority()) : ex_stack.top().drawList.end();
auto ivBG = drawListBG.begin();
const auto iedvBG = drawListBG.end();
auto DrawAndProceed = [&](DrawPriorityMap::iterator& iv)
auto DrawAndProceed = [](DrawPriorityMap::iterator& iv, DrawPriorityMap& drawList)
{
auto is = iv->second.lock();

Expand All @@ -305,8 +304,8 @@ namespace GTF
try{
#endif
while (ivBG != iedvBG && ivBG->first <= iv->first)
DrawAndProceed(ivBG);
DrawAndProceed(iv);
DrawAndProceed(ivBG, drawListBG);
DrawAndProceed(iv, ex_stack.top().drawList);
#ifdef _CATCH_WHILE_RENDER
}catch(...){
OutputLog("catch while draw : %X %s", *iv, typeid(*(*iv).lock()).name());
Expand All @@ -323,12 +322,12 @@ namespace GTF

//描画
assert(iv == iedv);
iedv = drawList.end();
iedv = ex_stack.top().drawList.end();
DrawAll();

// 書き残した常駐タスク処理
while (ivBG != iedvBG)
DrawAndProceed(ivBG);
DrawAndProceed(ivBG, drawListBG);
}

void CTaskManager::RemoveTaskByID(unsigned int id)
Expand Down Expand Up @@ -365,12 +364,6 @@ namespace GTF
}


//最上位にあるエクスクルーシブタスクをゲト
CTaskManager::ExTaskPtr CTaskManager::GetTopExclusiveTask()
{
return ex_stack.top().value;
}

//指定IDの排他タスクまでTerminate/popする
void CTaskManager::RevertExclusiveTaskByID(unsigned int id)
{
Expand Down
15 changes: 9 additions & 6 deletions src/system/task.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,10 @@ namespace GTF
BgTaskPtr AddTask(CBackgroundTaskBase *newTask); //!< 常駐タスク追加
void RemoveTaskByID(unsigned int id); //!< 指定IDを持つタスクの除去 ※注:Exclusiveタスクはチェックしない
void RevertExclusiveTaskByID(unsigned int id); //!< 指定IDの排他タスクまでTerminate/popする
ExTaskPtr GetTopExclusiveTask(); //!< 最上位にあるエクスクルーシブタスクをゲト
ExTaskPtr GetTopExclusiveTask() //!< 最上位にあるエクスクルーシブタスクをゲト
{
return ex_stack.top().value;
}

//!指定IDの通常タスク取得
TaskPtr FindTask(unsigned int id)
Expand All @@ -143,7 +146,7 @@ namespace GTF
//! 任意のクラス型のタスクを取得(通常・常駐兼用)
template<class T> shared_ptr<T> FindTask(unsigned int id)
{
return dynamic_pointer_cast<T>(FindTask_intl<T>(id).lock());
return dynamic_pointer_cast<T>(FindTask_impl<T>(id).lock());
}

void Execute(double elapsedTime); //!< 各タスクのExecute関数をコールする
Expand Down Expand Up @@ -187,13 +190,13 @@ namespace GTF
}

private:
template<class T, class = typename enable_if<!is_base_of<CBackgroundTaskBase, T>::value>::type>
TaskPtr FindTask_intl(unsigned int id)
template<class T, class = typename enable_if_t<!is_base_of<CBackgroundTaskBase, T>::value>>
TaskPtr FindTask_impl(unsigned int id)
{
return FindTask(id);
}
template<class T, class = typename enable_if<is_base_of<CBackgroundTaskBase, T>::value>::type>
BgTaskPtr FindTask_intl(unsigned int id)
template<class T, class = typename enable_if_t<is_base_of<CBackgroundTaskBase, T>::value>>
BgTaskPtr FindTask_impl(unsigned int id)
{
return FindBGTask(id);
}
Expand Down

0 comments on commit 553b2ef

Please sign in to comment.