Exemplo n.º 1
0
/**
 * @luafunc int LuaGameInfo::getEventScore(ScoringEvent event)
 *
 * @brief Get the value of a \ref ScoringEventEnum.
 *
 * @return The number of points earned when the \ref ScoringEventEnum 'event'
 * occurs, or zero of an unknown event is specified.
 */
S32 LuaGameInfo::lua_getEventScore(lua_State *L)
{
   static const char *methodName = "GameInfo:getEventScore()";
   checkArgCount(L, 1, methodName);
   ScoringEvent scoringEvent = (ScoringEvent) getInt(L, 1, methodName, 0, ScoringEventsCount - 1);

   return returnInt(L, mServerGame->getGameType()->getEventScore(GameType::TeamScore, scoringEvent, 0));
};
Exemplo n.º 2
0
/**
 * @luafunc int LuaGameInfo::getNexusTimeLeft()
 *
 * @brief The number of seconds until the nexus opens or closes.
 *
 * @return The number of seconds until the Nexus opens or closes, or nil if this
 * is not a nexus game.  If this function returns 0, the Nexus will remain in its 
 * current state until the end of the game
 */
S32 LuaGameInfo::lua_getNexusTimeLeft(lua_State *L)
{
   GameType *gameType = mServerGame->getGameType();
   if(!gameType || gameType->getGameTypeId() != NexusGame)
      return returnNil(L);

   return returnInt(L, static_cast<NexusGameType *>(gameType)->getNexusTimeLeftMs() / 1000);
}
Exemplo n.º 3
0
void Downloader::finishedLoadingPageCount(Page *page)
{
	if (m_cancelled)
		return;

	log("Received page '"+page->url().toString()+"'");

	if (--m_waiting > 0)
	{
		loadNext();
		return;
	}

	int total = 0;
	for (int i = 0; i < m_pagesC->size(); ++i)
		total += m_pagesC->at(i)->imagesCount();

	if (m_quit)
		returnInt(total);
	else
		emit finishedPageCount(total);
}
Exemplo n.º 4
0
S32 PlayerInfo::lua_getScore(lua_State *L)
{
   return returnInt(L, mClientInfo->getScore());
}
Exemplo n.º 5
0
S32 PolygonObject::getRad(lua_State *L)
{
   return returnInt(L, 0);
}
Exemplo n.º 6
0
/////////// JNICALL .._init ////////////
JNIEXPORT void JNICALL Java_ondrej_platek_bind_NativeRenderer_initV(JNIEnv * env, jobject mythis,jobjectArray npo, jobjectArray Faces)  {
    int ic = extractInt(env, mythis,"pAppCtx");
    LOGI("AppCtx pointer at beggining init: %d",ic);
    AppCtx * c =  reinterpret_cast<AppCtx*>(ic);
    if(c == NULL) { // create new AppCtx -> should be only 1
        c = new AppCtx();
        LOGI("AppCtx pointer initialize in init: %d",c);
    }
    else {
        releaseVertexRes(c);
    }

    int vert_raw_size = extractInt(env, mythis, "vertices_size");
    int norm_raw_size = extractInt(env, mythis, "normals_size");
    c->parts_number = extractInt(env, mythis, "parts_number");

    // jArrays -> I have to release them afterwards
    jobject mvdata = objForArray(env, mythis, "vertices", "[F");
    jfloatArray * arr = reinterpret_cast<jfloatArray*>(&mvdata);
    float * raw_vertices = env->GetFloatArrayElements(*arr, NULL);

    mvdata = objForArray(env, mythis, "normals", "[F");
    jfloatArray * arr1 = reinterpret_cast<jfloatArray*>(&mvdata);
    float * raw_normals = env->GetFloatArrayElements(*arr1, NULL);


    mvdata = objForArray(env, mythis, "parts_sizes", "[I");
    jintArray * arr2 = reinterpret_cast<jintArray*>(&mvdata);
    int * raw_parts_sizes = env->GetIntArrayElements(*arr2, NULL);

    c->parts_sizes = new int[c->parts_number];
    // TODO memcpy
    for(int i = 0; i < c->parts_number; i++) {
        c->parts_sizes[i] = raw_parts_sizes[i];
    }

    c->faces = new GLuint*[c->parts_number];
    GLuint ** np = new GLuint*[c->parts_number];
    for(int i = 0; i < c->parts_number; i++) {
         jshortArray oneDimFaces = (jshortArray) env->GetObjectArrayElement(Faces, i);
         jshortArray oneDimNormP = (jshortArray)env->GetObjectArrayElement(npo, i);
         jshort * arrface =env->GetShortArrayElements(oneDimFaces, 0);
         jshort * arrnorm =env->GetShortArrayElements(oneDimNormP, 0);
         c->faces[i] = new GLuint[c->parts_sizes[i]];
         np[i] = new GLuint[c->parts_sizes[i]];
         for(int j = 0; j < c->parts_sizes[i]; j++) { // each part could have different number of vertices
            c->faces[i][j] = arrface[j];
            np[i][j]= arrnorm[j];
         }
    }

    // delete np, fill vertices, change faces
    c->vertices = separateVertices(&c->numVertices, raw_vertices,
        raw_normals, c->faces, np, c->parts_sizes, c->parts_number);


    // Don't forget to release it
    env->ReleaseFloatArrayElements(*arr, raw_vertices, JNI_ABORT);
    env->ReleaseFloatArrayElements(*arr1, raw_normals, JNI_ABORT);
    env->ReleaseIntArrayElements(*arr2, raw_parts_sizes, JNI_ABORT);

    // return AppCtx c
    int retValue = reinterpret_cast<int>(c);
    LOGI("AppCtx pointer at the end of init: %d",retValue);
    returnInt(env, mythis,"pAppCtx", retValue);
}
Exemplo n.º 7
0
/**
 * @luafunc int Team::getPlayerCount()
 *
 * @brief Get the number of players currently on this team.
 *
 * @return The number of players currently on this team.
 */
S32 Team::lua_getPlayerCount(lua_State *L)
{
   GameManager::getServerGame()->countTeamPlayers();    // Make sure player counts are up-to-date
   return returnInt(L, mPlayerCount);
}
Exemplo n.º 8
0
/**
 * @luafunc int Team::getScore()
 *
 * @brief Get the team's current score.
 *
 * @return The team's current score.
 */
S32 Team::lua_getScore(lua_State *L)
{
   return returnInt(L, mScore);
}
Exemplo n.º 9
0
/**
 * @luafunc int Team::getIndex()
 *
 * @brief Get the numerical index of this Team.
 *
 * @return The numerical index of this Team.
 */
S32 Team::lua_getIndex(lua_State *L)
{
   return returnInt(L, mTeamIndex + 1);
}
Exemplo n.º 10
0
/**
 * @luafunc int LuaGameInfo::getGameTimeTotal()
 *
 * @brief Get the initial time limit of the game in seconds.
 *
 * @return The initial time limit of the game in seconds.
 */
S32 LuaGameInfo::lua_getGameTimeTotal(lua_State *L) { return returnInt (L, mServerGame->getGameType()->getTotalGameTime()); }
Exemplo n.º 11
0
/**
 * @luafunc int LuaGameInfo::getTeamCount()
 * 
 * @brief Get the number of teams in the game.
 * 
 * @return The number of teams in the game.
 */
S32 LuaGameInfo::lua_getTeamCount(lua_State *L) { return returnInt (L, mServerGame->getTeamCount()); }
Exemplo n.º 12
0
/**
 * @luafunc int LuaGameInfo::getLeadingTeam()
 *
 * @brief Get the index of the team with the highest score.
 *
 * @return The index of the team with the highest score.
 */
S32 LuaGameInfo::lua_getLeadingTeam(lua_State *L) { return returnInt (L, mServerGame->getGameType()->getLeadingTeam() + 1); }
Exemplo n.º 13
0
/**
 * @luafunc int LuaGameInfo::getLeadingScore()
 *
 * @brief Get the highest score among all teams.
 *
 * @return The highest score among all teams.
 */
S32 LuaGameInfo::lua_getLeadingScore(lua_State *L) { return returnInt (L, mServerGame->getGameType()->getLeadingScore()); }
Exemplo n.º 14
0
/**
 * @luafunc int LuaGameInfo::getGameTimeRemaining()
 *
 * @brief Get the number of seconds until the game ends.
 *
 * @return The number of seconds until the game ends.
 */
S32 LuaGameInfo::lua_getGameTimeRemaining(lua_State *L) { return returnInt (L, mServerGame->getGameType()->getRemainingGameTime()); }
Exemplo n.º 15
0
S32 RobotPlayerInfo::lua_getScore(lua_State *L)
{
   return returnInt(L, mRobot->getClientInfo()->getScore());
}
Exemplo n.º 16
0
/**
 * @luafunc GameType LuaGameInfo::getGameType()
 * 
 * @brief Get the \ref GameTypeEnum of the current game.
 * 
 * @desc For possible values, see \ref GameTypeEnum.
 * 
 * @code
 *   print(info:getGameType() == GameType.CTFGameType) -- `true` when playing CTF
 * @endcode
 * 
 * @return A member of \ref GameTypeEnum.
 */
S32 LuaGameInfo::lua_getGameType(lua_State *L)
{
   TNLAssert(mServerGame->getGameType(), "Need Gametype check in getGameType");
   return returnInt(L, mServerGame->getGameType()->getGameTypeId());
}
Exemplo n.º 17
0
/**
 * @luafunc int LuaGameInfo::getFlagCount()
 *
 * @brief Get the number of flags in play.
 *
 * @return The number of flags in play.
 */
S32 LuaGameInfo::lua_getFlagCount(lua_State *L) { return returnInt (L, mServerGame->getGameType()->getFlagCount()); }