| 1076 | */ |
| 1077 | |
| 1078 | int CTaskManager::Wait( CTask *task, bool &completed , CIcarus* icarus ) |
| 1079 | { |
| 1080 | CBlockMember *bm; |
| 1081 | CBlock *block = task->GetBlock(); |
| 1082 | char *sVal; |
| 1083 | float dwtime; |
| 1084 | int memberNum = 0; |
| 1085 | |
| 1086 | completed = false; |
| 1087 | |
| 1088 | bm = block->GetMember( 0 ); |
| 1089 | |
| 1090 | //Check if this is a task completion wait |
| 1091 | if ( bm->GetID() == CIcarus::TK_STRING ) |
| 1092 | { |
| 1093 | ICARUS_VALIDATE( Get( m_ownerID, block, memberNum, &sVal, icarus ) ); |
| 1094 | |
| 1095 | if ( task->GetTimeStamp() == icarus->GetGame()->GetTime() ) |
| 1096 | { |
| 1097 | //Print out the debug info |
| 1098 | icarus->GetGame()->DebugPrint(IGameInterface::WL_DEBUG, "%4d wait(\"%s\"); [%d]", m_ownerID, sVal, task->GetTimeStamp() ); |
| 1099 | } |
| 1100 | |
| 1101 | CTaskGroup *group = GetTaskGroup( sVal , icarus); |
| 1102 | |
| 1103 | if ( group == NULL ) |
| 1104 | { |
| 1105 | //TODO: Emit warning |
| 1106 | completed = false; |
| 1107 | return TASK_FAILED; |
| 1108 | } |
| 1109 | |
| 1110 | completed = group->Complete(); |
| 1111 | } |
| 1112 | else //Otherwise it's a time completion wait |
| 1113 | { |
| 1114 | if ( Check( CIcarus::ID_RANDOM, block, memberNum ) ) |
| 1115 | {//get it random only the first time |
| 1116 | float min, max; |
| 1117 | |
| 1118 | dwtime = *(float *) block->GetMemberData( memberNum++ ); |
| 1119 | if ( dwtime == icarus->GetGame()->MaxFloat() ) |
| 1120 | {//we have not evaluated this random yet |
| 1121 | min = *(float *) block->GetMemberData( memberNum++ ); |
| 1122 | max = *(float *) block->GetMemberData( memberNum++ ); |
| 1123 | |
| 1124 | dwtime = icarus->GetGame()->Random( min, max ); |
| 1125 | |
| 1126 | //store the result in the first member |
| 1127 | bm->SetData( &dwtime, sizeof( dwtime ) , icarus); |
| 1128 | } |
| 1129 | } |
| 1130 | else |
| 1131 | { |
| 1132 | ICARUS_VALIDATE( GetFloat( m_ownerID, block, memberNum, dwtime, icarus ) ); |
| 1133 | } |
| 1134 | |
| 1135 | if ( task->GetTimeStamp() == icarus->GetGame()->GetTime() ) |
nothing calls this directly
no test coverage detected