ShiVa Developer Forum • View topic - C++ Error?
 

C++ Error?

Google Play Store, Amazon Kindle, Nook, and so many more

C++ Error?

Postby giggsy » 2018-04-04 10:00

Hi,

I am trying to create an Android C++ build with 2.0.

I got this piece of stonescript:
Code: Select all
--------------------------------------------------------------------------------
function TradeWarController.calcExchangeRate ( sNpcId, nMinRate, nMaxRate, nAmount, bAsString )
--------------------------------------------------------------------------------
   
    local nProgress = this.calcProgressByNpcId ( sNpcId )
    if( nProgress == nil )
    then
        return nil, nil
    end
   
    nMinRate = nMinRate * 1000
    nMaxRate = nMaxRate * 1000
   
    local nRate = nMaxRate - (nMaxRate - nMinRate) * nProgress
    nRate = nRate / 1000
    if(nRate < 1.0)
    then
        nAmount = nAmount * (1/nRate)
        nRate = 1
    end
    nRate = math.roundToNearestInteger( nRate )
    nAmount = math.roundToNearestInteger( nAmount )
   
    if( bAsString == true )
    then
        if( nRate > 999999)
        then
            return ((nRate / 1000) .. "k"), (nAmount .. "")
        else
            return (nRate .. ""), (nAmount .. "")
        end
    else
        return nRate, nAmount
    end
   
--------------------------------------------------------------------------------
end
--------------------------------------------------------------------------------



Which translates to:
Code: Select all
//------------------------------------------------------------------------------
#include "TradeWarController.h"
//------------------------------------------------------------------------------
using namespace S3DX;
//------------------------------------------------------------------------------
AIVariables<2> TradeWarController::calcExchangeRate ( AIVariable sNpcId, AIVariable nMinRate, AIVariable nMaxRate, AIVariable nAmount, AIVariable bAsString )
{
    AIVariable nProgress = this->calcProgressByNpcId(sNpcId);
    if ( (nProgress == nil) )
    {
        return AIVariables<2>( nil, nil );
    }
    nMinRate = nMinRate * 1000.0f;
    nMaxRate = nMaxRate * 1000.0f;
    AIVariable nRate = nMaxRate - (nMaxRate - nMinRate) * nProgress;
    nRate = nRate / 1000.0f;
    if ( (nRate < 1.0f) )
    {
        nAmount = nAmount * (1.0f / nRate);
        nRate = 1.0f;
    }
    nRate = math.roundToNearestInteger(nRate);
    nAmount = math.roundToNearestInteger(nAmount);
    if ( (bAsString == true) )
    {
        if ( (nRate > 999999.0f) )
        {
            return AIVariables<2>( (AIVariable((nRate / 1000.0f)) << AIVariable("k")), (AIVariable(nAmount) << AIVariable("")) );
        }
        else
        {
            return AIVariables<2>( (AIVariable(nRate) << AIVariable("")), (AIVariable(nAmount) << AIVariable("")) );
        }
    }
    else
    {
        return AIVariables<2>( nRate, nAmount );
    }
}
//------------------------------------------------------------------------------


And, most notably, this header file:
Code: Select all
//------------------------------------------------------------------------------
#ifndef __TradeWarController_h__
#define __TradeWarController_h__
//------------------------------------------------------------------------------
#include "S3DX/S3DXAIModel.h"
#include "FantasyIsland_Plugins.h"
//------------------------------------------------------------------------------
S3DX_DECLARE_AIMODEL( TradeWarController )
{
public:
   
    // Handlers:
    //
    S3DX_DECLARE_HANDLER( onInit );
    S3DX_DECLARE_HANDLER( onDebug );
    S3DX_DECLARE_HANDLER( onTrade );
    S3DX_DECLARE_HANDLER( onAddToUser );
    S3DX_DECLARE_HANDLER( onQuestSeen );
    S3DX_DECLARE_HANDLER( onUpdateTask );
    S3DX_DECLARE_HANDLER( onCalcProgress );
    S3DX_DECLARE_HANDLER( onCheckIfActive );
    S3DX_DECLARE_HANDLER( onAddRandomQuest );
    S3DX_DECLARE_HANDLER( onLogEnvironment );
    S3DX_DECLARE_HANDLER( onRemoveFromUser );
    S3DX_DECLARE_HANDLER( onMonumentTouched );
    S3DX_DECLARE_HANDLER( onCalcExchangeRate );
    S3DX_DECLARE_HANDLER( onGetCurrentAmount );
    S3DX_DECLARE_HANDLER( onGetNpcFieldValue );
    S3DX_DECLARE_HANDLER( onIsRecipeUnlocked );
    S3DX_DECLARE_HANDLER( onSetMonumentLevel );
    S3DX_DECLARE_HANDLER( onSetTutorialShown );
    S3DX_DECLARE_HANDLER( onShowNewQuestHint );
    S3DX_DECLARE_HANDLER( onSetNpcActiveState );
    S3DX_DECLARE_HANDLER( onGetNumOfActiveNpcs );
    S3DX_DECLARE_HANDLER( onShowParticleEffect );
    S3DX_DECLARE_HANDLER( onCreateTutorialArrow );
    S3DX_DECLARE_HANDLER( onGetLevelForMonument );
    S3DX_DECLARE_HANDLER( onRewardInstantFinish );
    S3DX_DECLARE_HANDLER( onDestroyTutorialArrow );
    S3DX_DECLARE_HANDLER( onLongTextHasBeenShown );
    S3DX_DECLARE_HANDLER( onRemoveParticleEffect );
    S3DX_DECLARE_HANDLER( onUpdateNpcActiveState );
    S3DX_DECLARE_HANDLER( onUpdateNpcActiveStates );
    S3DX_DECLARE_HANDLER( onUpdateMonumentProgress );
    S3DX_DECLARE_HANDLER( onCalcProgressForMonument );
    S3DX_DECLARE_HANDLER( onAnalyticsTrackTaskOpened );
    S3DX_DECLARE_HANDLER( onAnalyticsTrackQuestOpened );
    S3DX_DECLARE_HANDLER( onShowMonumentFinishedEffect );
    S3DX_DECLARE_HANDLER( onAnalyticsTrackQuestProgress );
    S3DX_DECLARE_HANDLER( onAnalyticsTrackTaskCompleted );
    S3DX_DECLARE_HANDLER( onAnalyticsTrackQuestCompleted );
    S3DX_DECLARE_HANDLER( onReadCoinsAndBucksAmountOnTaskShow );
    S3DX_DECLARE_HANDLER( onAnalyticsTrackQuestActiveStateChanged );
    S3DX_DECLARE_HANDLER( onAnalyticsTrackMonumentBuildButtonPressed );
   
    // States:
    //
   
    // Functions:
    //
    void init ( );
    void trade ( S3DX::AIVariable sName = S3DX::nil, S3DX::AIVariable sId = S3DX::nil );
    S3DX::AIVariable getText ( S3DX::AIVariable sId = S3DX::nil, S3DX::AIVariable sDefault = S3DX::nil );
    S3DX::AIVariable hasEvent ( S3DX::AIVariable htNPC = S3DX::nil, S3DX::AIVariable sEventType = S3DX::nil );
    S3DX::AIVariable addToUser ( S3DX::AIVariable sName = S3DX::nil, S3DX::AIVariable sType = S3DX::nil, S3DX::AIVariable nAmount = S3DX::nil, S3DX::AIVariable nTypeIndex = S3DX::nil, S3DX::AIVariable sReason = S3DX::nil );
    S3DX::AIVariable getNpcById ( S3DX::AIVariable sNpcId = S3DX::nil, S3DX::AIVariable sKey = S3DX::nil );
    void persistNpc ( S3DX::AIVariable sNpcId = S3DX::nil, S3DX::AIVariable htNpc = S3DX::nil, S3DX::AIVariable bPersistTasks = S3DX::nil, S3DX::AIVariable bFlush = S3DX::nil );
    void updateTask ( S3DX::AIVariable sName = S3DX::nil );
    S3DX::AIVariable getABReturn ( );
    void persistTask ( S3DX::AIVariable sNpcId = S3DX::nil, S3DX::AIVariable nTaskIndex = S3DX::nil, S3DX::AIVariable htTask = S3DX::nil, S3DX::AIVariable bFlush = S3DX::nil );
    S3DX::AIVariable xml_getAttr ( S3DX::AIVariable hXmlElement = S3DX::nil, S3DX::AIVariable sAttributeName = S3DX::nil, S3DX::AIVariable defaultValue = S3DX::nil, S3DX::AIVariable bUseFirstCharAsTypeHint = S3DX::nil );
    S3DX::AIVariable calcProgress ( S3DX::AIVariable tTasks = S3DX::nil );
    void checkIfActive ( );
    S3DX::AIVariable getNpcByField ( S3DX::AIVariable sFieldName = S3DX::nil, S3DX::AIVariable vFieldValue = S3DX::nil, S3DX::AIVariable sKey = S3DX::nil );
    void addRandomQuest ( );
    S3DX::AIVariables<5> getProductInfo ( S3DX::AIVariable productId = S3DX::nil );
    S3DX::AIVariable getTaskByIndex ( S3DX::AIVariable sNpcId = S3DX::nil, S3DX::AIVariable nTaskIndex = S3DX::nil );
    void logEnvironment ( S3DX::AIVariable sBase = S3DX::nil );
    S3DX::AIVariables<2> removeFromUser ( S3DX::AIVariable sName = S3DX::nil, S3DX::AIVariable sType = S3DX::nil, S3DX::AIVariable nAmount = S3DX::nil, S3DX::AIVariable nTypeIndex = S3DX::nil, S3DX::AIVariable sReason = S3DX::nil );
    S3DX::AIVariable updateProgress ( S3DX::AIVariable sName = S3DX::nil, S3DX::AIVariable tTasks = S3DX::nil, S3DX::AIVariable nPercent = S3DX::nil, S3DX::AIVariable htNpc = S3DX::nil );
    S3DX::AIVariables<3> calcExchangeRate ( S3DX::AIVariable sNpcId = S3DX::nil, S3DX::AIVariable nMinRate = S3DX::nil, S3DX::AIVariable nMaxRate = S3DX::nil, S3DX::AIVariable nAmount = S3DX::nil, S3DX::AIVariable bAsString = S3DX::nil );
    S3DX::AIVariable getCurrentAmount ( S3DX::AIVariable sType = S3DX::nil, S3DX::AIVariable nTypeIndex = S3DX::nil, S3DX::AIVariable bTaskAware = S3DX::nil );
    S3DX::AIVariable isRecipeUnlocked ( S3DX::AIVariable nRecipeId = S3DX::nil );
    void setTutorialShown ( S3DX::AIVariable bShown = S3DX::nil );
    S3DX::AIVariable getEnvironmentVar ( S3DX::AIVariable sVar = S3DX::nil, S3DX::AIVariable vDefaultValue = S3DX::nil );
    void setNpcActiveState ( S3DX::AIVariable sNpcId = S3DX::nil, S3DX::AIVariable bActive = S3DX::nil );
    S3DX::AIVariable xml_typeCastValue ( S3DX::AIVariable sType = S3DX::nil, S3DX::AIVariable vValue = S3DX::nil );
    void ShowParticleEffect ( S3DX::AIVariable sEffectName = S3DX::nil, S3DX::AIVariable nEffectDuration = S3DX::nil, S3DX::AIVariable nEffectPosX = S3DX::nil, S3DX::AIVariable nEffectPosY = S3DX::nil, S3DX::AIVariable nEffectPosZ = S3DX::nil );
    S3DX::AIVariable getNumOfActiveNpcs ( );
    S3DX::AIVariable calcProgressByNpcId ( S3DX::AIVariable sNpcId = S3DX::nil );
    void createTutorialArrow ( S3DX::AIVariable sDirection = S3DX::nil, S3DX::AIVariable nX = S3DX::nil, S3DX::AIVariable nY = S3DX::nil, S3DX::AIVariable nAutoDeleteAfterNSeconds = S3DX::nil, S3DX::AIVariable sName = S3DX::nil, S3DX::AIVariable bWorld = S3DX::nil );
    S3DX::AIVariable xml_getElementValue ( S3DX::AIVariable hXml = S3DX::nil, S3DX::AIVariable sDefaultValue = S3DX::nil );
    void destroyTutorialArrow ( );
    S3DX::AIVariables<2> getNpcStatsInMinutes ( S3DX::AIVariable tTasks = S3DX::nil );
    void updateNpcActiveState ( S3DX::AIVariable sId = S3DX::nil, S3DX::AIVariable bChanged = S3DX::nil );
    S3DX::AIVariable getRandomProductIndex ( );
    S3DX::AIVariables<2> getTaskStatsInMinutes ( S3DX::AIVariable nProgress = S3DX::nil, S3DX::AIVariable sType = S3DX::nil, S3DX::AIVariable nTypeIndex = S3DX::nil, S3DX::AIVariable nTypeAmount = S3DX::nil, S3DX::AIVariable nCoinsToMinutes = S3DX::nil, S3DX::AIVariable nBucksToMinutes = S3DX::nil );
    void updateNpcActiveStates ( );
    void sendEventWithParameters ( S3DX::AIVariable hUser = S3DX::nil, S3DX::AIVariable sAi = S3DX::nil, S3DX::AIVariable sHandler = S3DX::nil, S3DX::AIVariable tParams = S3DX::nil, S3DX::AIVariable bSendImmediate = S3DX::nil, S3DX::AIVariable nDelay = S3DX::nil );
    S3DX::AIVariable convertProductIdToCCAndWE ( S3DX::AIVariable sPrefix = S3DX::nil, S3DX::AIVariable nId = S3DX::nil );
    void triggerNpcEventIfAvailable ( S3DX::AIVariable htNPC = S3DX::nil, S3DX::AIVariable sEventType = S3DX::nil, S3DX::AIVariable bSendImmediate = S3DX::nil );
    S3DX::AIVariable calcRandomQuestRewardAmount ( S3DX::AIVariable nFactoryIdForObjective = S3DX::nil, S3DX::AIVariable nObjAmount = S3DX::nil, S3DX::AIVariable nFactoryIdForReward = S3DX::nil );
    void readCoinsAndBucksAmountOnTaskShow ( );
   
    // Variables:
    //
    S3DX_DECLARE_VARIABLE( htNPCs );
    S3DX_DECLARE_VARIABLE( bActive );
    S3DX_DECLARE_VARIABLE( bReturn );
    S3DX_DECLARE_VARIABLE( nReturn );
    S3DX_DECLARE_VARIABLE( sReturn );
    S3DX_DECLARE_VARIABLE( vReturn );
    S3DX_DECLARE_VARIABLE( htConfig );
    S3DX_DECLARE_VARIABLE( nReturn2 );
    S3DX_DECLARE_VARIABLE( sReturn2 );
    S3DX_DECLARE_VARIABLE( _b_ENABLED );
    S3DX_DECLARE_VARIABLE( bVisitorMode );
    S3DX_DECLARE_VARIABLE( sCurrentNpcId );
    S3DX_DECLARE_VARIABLE( bTutorialShown );
    S3DX_DECLARE_VARIABLE( nBucksAvailable );
    S3DX_DECLARE_VARIABLE( nCoinsAvailable );
    S3DX_DECLARE_VARIABLE( nBucksAtTaskShow );
    S3DX_DECLARE_VARIABLE( nCoinsAtTaskShow );
    S3DX_DECLARE_VARIABLE( nCurrentTaskIndex );
    S3DX_DECLARE_VARIABLE( bItemsInWorldLocked );
    S3DX_DECLARE_VARIABLE( nTmpLastNpcProgress );
    S3DX_DECLARE_VARIABLE( sTmpLastNpcProgressId );
    S3DX_DECLARE_VARIABLE( sTutorialArrowHudName );
    S3DX_DECLARE_VARIABLE( nTutorialArrowAutoDeleteEventNr );

};
//------------------------------------------------------------------------------
#endif // __TradeWarController_h__
//------------------------------------------------------------------------------



Now the problem is I guess this:
Code: Select all
S3DX::AIVariables<3> calcExchangeRate ( S3DX::AIVariable sNpcId = S3DX::nil, S3DX::AIVariable nMinRate = S3DX::nil, S3DX::AIVariable nMaxRate = S3DX::nil, S3DX::AIVariable nAmount = S3DX::nil, S3DX::AIVariable bAsString = S3DX::nil );


It returns 3 AIVars, instead of 2.
Any clue?

This is the compile error I get:
Code: Select all
FAILED: C:\Programs\android-sdk\ndk-bundle\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64\bin\arm-linux-androideabi-g++.exe  --sysroot=C:/Programs/android-sdk/ndk-bundle/sysroot  -DS3DClient_EXPORTS -I../../../../src/main/jni -I../../../../src/main/jni/AIModels -I../../../../src/main/jni/S3DX -isystem C:/Programs/android-sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include -isystem C:/Programs/android-sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include -isystem C:/Programs/android-sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/backward -isystem C:/Programs/android-sdk/ndk-bundle/sysroot/usr/include/arm-linux-androideabi -D__ANDROID_API__=27 -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -Wa,--noexecstack -Wformat -Werror=format-security   -DANDROID_NDK -Wno-psabi -Os -DNDEBUG  -fPIC -MD -MT CMakeFiles/S3DClient.dir/src/main/jni/AIModels/TradeWarController_Function_calcExchangeRate.cpp.o -MF CMakeFiles\S3DClient.dir\src\main\jni\AIModels\TradeWarController_Function_calcExchangeRate.cpp.o.d -o CMakeFiles/S3DClient.dir/src/main/jni/AIModels/TradeWarController_Function_calcExchangeRate.cpp.o -c D:\SocialGamesOld\android-new\FantasyIsland\FantasyIsland\src\main\jni\AIModels\TradeWarController_Function_calcExchangeRate.cpp
D:\SocialGamesOld\android-new\FantasyIsland\FantasyIsland\src\main\jni\AIModels\TradeWarController_Function_calcExchangeRate.cpp:6:16: error: prototype for 'S3DX::AIVariables<2u> TradeWarController::calcExchangeRate(S3DX::AIVariable, S3DX::AIVariable, S3DX::AIVariable, S3DX::AIVariable, S3DX::AIVariable)' does not match any in class 'TradeWarController'
 AIVariables<2> TradeWarController::calcExchangeRate ( AIVariable sNpcId, AIVariable nMinRate, AIVariable nMaxRate, AIVariable nAmount, AIVariable bAsString )
                ^
In file included from D:\SocialGamesOld\android-new\FantasyIsland\FantasyIsland\src\main\jni\AIModels\TradeWarCon
troller_Function_calcExchangeRate.cpp:2:0:
D:\SocialGamesOld\android-new\FantasyIsland\FantasyIsland\src\main\jni\AIModels\TradeWarController.h:81:26: error: candidate is: S3DX::AIVariables<3u> TradeWarController::calcExchangeRate(S3DX::AIVariable, S3DX::AIVariable, S3DX::AIVariable, S3DX::AIVariable, S3DX::AIVariable)
     S3DX::AIVariables<3> calcExchangeRate ( S3DX::AIVariable sNpcId = S3DX::nil, S3DX::AIVariable nMinRate = S3DX::nil, S3DX::AIVariable nMaxRate = S3DX::nil, S3DX::AIVariable nAmount = S3DX::nil, S3DX::AIVariable bAsString = S3DX::nil );
                          ^
ninja: build stopped: subcommand failed.
:FantasyIsland:externalNativeBuildRelease FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':FantasyIsland:externalNativeBuildRelease'.
> Build command failed.


Build fails both: Shiva APK direct or via gradle per shell.
If I remember correctly, I think I once read something, that the new 2.0 LUA interpreter is much faster?
And devices have gottten better, so we might as well ship a LUA update ... (we had performance problems in the past with big savegames on older devices).
So not too urgent on our side.
giggsy
Platinum Boarder
Platinum Boarder
 
Posts: 1153
Joined: 2010-06-27 21:17
Location: Austria

Re: C++ Error?

Postby broozar » 2018-04-12 12:32

confirmed. thanks for reporting, will do an internal ticket.

ShiVa 2.0 has 2 Lua runtimes, one for the engine (5.0.3) and one for the editor (5.2.3). The one for the engine is currently unchanged from 1.9.2 for backwards compatibility and should perform the same, although we might raise the interpreter version at some point, possibly at the cost of breaking 1.9.2 compatibility. What really should be giving a performance boost is the new core renderer, which has been implemented since beta3/4.
User avatar
broozar
Administrator
Administrator
 
Posts: 4147
Joined: 2007-09-16 10:22
Location: Berlin - Germany

Re: C++ Error?

Postby giggsy » 2018-04-12 13:23

Thanks for confirming and the info!
giggsy
Platinum Boarder
Platinum Boarder
 
Posts: 1153
Joined: 2010-06-27 21:17
Location: Austria


Return to Google Android

Who is online

Users browsing this forum: No registered users and 6 guests

cron