mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2026-11-18 09:46:19 -06:00
Pass immutable games list to NetplayUICallbacks
Remove corresponding jni config. Rename Netplay to NetplaySession in jni config to match new kotlin name.
This commit is contained in:
@@ -15,7 +15,6 @@
|
||||
#include "Core/NetPlayClient.h"
|
||||
#include "Core/NetPlayServer.h"
|
||||
#include "UICommon/GameFile.h"
|
||||
#include "UICommon/GameFileCache.h"
|
||||
|
||||
#include "jni/AndroidCommon/AndroidCommon.h"
|
||||
#include "jni/AndroidCommon/IDCache.h"
|
||||
@@ -75,17 +74,21 @@ Java_org_dolphinemu_dolphinemu_features_netplay_NetplaySession_nativeAdjustServe
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL
|
||||
Java_org_dolphinemu_dolphinemu_features_netplay_NetplaySession_nativeCreateUICallbacks(JNIEnv* env,
|
||||
jobject obj)
|
||||
Java_org_dolphinemu_dolphinemu_features_netplay_NetplaySession_nativeCreateUICallbacks(
|
||||
JNIEnv* env, jobject obj, jobjectArray jgame_files)
|
||||
{
|
||||
jobject jgame_file_cache = env->GetStaticObjectField(
|
||||
IDCache::GetGameFileCacheManagerClass(), IDCache::GetGameFileCacheManagerInstance());
|
||||
auto* game_file_cache = reinterpret_cast<UICommon::GameFileCache*>(
|
||||
env->GetLongField(jgame_file_cache, IDCache::GetGameFileCachePointer()));
|
||||
|
||||
std::vector<std::shared_ptr<const UICommon::GameFile>> games;
|
||||
game_file_cache->ForEach(
|
||||
[&games](const std::shared_ptr<const UICommon::GameFile>& game) { games.push_back(game); });
|
||||
const jsize count = env->GetArrayLength(jgame_files);
|
||||
games.reserve(count);
|
||||
for (jsize i = 0; i < count; i++)
|
||||
{
|
||||
jobject jgame_file = env->GetObjectArrayElement(jgame_files, i);
|
||||
auto* game_ptr = reinterpret_cast<std::shared_ptr<const UICommon::GameFile>*>(
|
||||
env->GetLongField(jgame_file, IDCache::GetGameFilePointer()));
|
||||
if (game_ptr)
|
||||
games.push_back(*game_ptr);
|
||||
env->DeleteLocalRef(jgame_file);
|
||||
}
|
||||
|
||||
return reinterpret_cast<jlong>(new NetPlay::NetPlayUICallbacks(obj, std::move(games)));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user