Skip to content

Commit bad7d8a

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 522aa85 + 10bfe7f commit bad7d8a

49 files changed

Lines changed: 848 additions & 288 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CMakeLists.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3862,9 +3862,14 @@ foreach(target ${TARGETS_OWN})
38623862
endif()
38633863
if(TARGET_OS STREQUAL "android")
38643864
if(ANDROID_PACKAGE_NAME)
3865-
target_compile_definitions(${target} PRIVATE ANDROID_PACKAGE_NAME=${ANDROID_PACKAGE_NAME})
3865+
target_compile_definitions(${target} PRIVATE ANDROID_PACKAGE_NAME="${ANDROID_PACKAGE_NAME}")
38663866
else()
3867-
message(FATAL_ERROR "ANDROID_PACKAGE_NAME must define the package name when compiling for Android (using underscores instead of dots, e.g. org_example_app)")
3867+
message(FATAL_ERROR "ANDROID_PACKAGE_NAME must define the package name when compiling for Android (e.g. org.example.app)")
3868+
endif()
3869+
if(ANDROID_PACKAGE_NAME_JNI)
3870+
target_compile_definitions(${target} PRIVATE ANDROID_PACKAGE_NAME_JNI=${ANDROID_PACKAGE_NAME_JNI})
3871+
else()
3872+
message(FATAL_ERROR "ANDROID_PACKAGE_NAME_JNI must define the package name when compiling for Android (using underscores instead of dots, e.g. org_example_app)")
38683873
endif()
38693874
endif()
38703875
endforeach()

datasrc/network.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
]
2525
GameInfoFlags2 = [
2626
"ALLOW_X_SKINS", "GAMETYPE_CITY", "GAMETYPE_FDDRACE", "ENTITIES_FDDRACE", "HUD_HEALTH_ARMOR", "HUD_AMMO",
27-
"HUD_DDRACE", "NO_WEAK_HOOK", "NO_SKIN_CHANGE_FOR_FROZEN", "DDRACE_TEAM"
27+
"HUD_DDRACE", "NO_WEAK_HOOK", "NO_SKIN_CHANGE_FOR_FROZEN", "DDRACE_TEAM", "PREDICT_EVENTS"
2828
]
2929
ExPlayerFlags = ["AFK", "PAUSED", "SPEC"]
3030
LegacyProjectileFlags = [f"CLIENTID_BIT{i}" for i in range(8)] + [
@@ -77,7 +77,7 @@
7777
7878
enum
7979
{
80-
GAMEINFO_CURVERSION=10,
80+
GAMEINFO_CURVERSION=11,
8181
};
8282
'''
8383

@@ -659,4 +659,8 @@
659659
NetMessageEx("Cl_EnableSpectatorCount", "enable-spectator-count@netmsg.ddnet.org", [
660660
NetBool("m_Enable"),
661661
]),
662+
663+
NetMessageEx("Sv_MapInfo", "map-info@netmsg.ddnet.org", [
664+
NetString("m_pDescription"),
665+
]),
662666
]

scripts/android/cmake_android.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ function build_for_type() {
157157
-DCMAKE_ANDROID_ARCH_ABI="${2}" \
158158
-DCARGO_NDK_TARGET="${3}" \
159159
-DCARGO_NDK_API="$ANDROID_API" \
160-
-DANDROID_PACKAGE_NAME="${PACKAGE_NAME//./_}" \
160+
-DANDROID_PACKAGE_NAME="${PACKAGE_NAME}" \
161+
-DANDROID_PACKAGE_NAME_JNI="${PACKAGE_NAME//./_}" \
161162
-DPREFER_BUNDLED_LIBS=ON \
162163
-DSERVER=ON \
163164
-DTOOLS=OFF \

src/base/log.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,10 @@ class CLoggerAndroid : public ILogger
160160
case LEVEL_WARN: AndroidLevel = ANDROID_LOG_WARN; break;
161161
case LEVEL_ERROR: AndroidLevel = ANDROID_LOG_ERROR; break;
162162
}
163-
__android_log_write(AndroidLevel, pMessage->m_aSystem, pMessage->Message());
163+
char aTag[64];
164+
str_copy(aTag, ANDROID_PACKAGE_NAME "/");
165+
str_append(aTag, pMessage->m_aSystem);
166+
__android_log_write(AndroidLevel, aTag, pMessage->Message());
164167
}
165168
};
166169
std::unique_ptr<ILogger> log_logger_android()

src/engine/client/serverbrowser.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,13 @@ const CServerInfo *CServerBrowser::SortedGet(int Index) const
322322
return &m_vpServerlist[m_vSortedServerlist[Index]]->m_Info;
323323
}
324324

325+
const CServerInfo *CServerBrowser::Get(int Index) const
326+
{
327+
if(Index < 0 || Index >= (int)m_vpServerlist.size())
328+
return nullptr;
329+
return &m_vpServerlist[Index]->m_Info;
330+
}
331+
325332
int CServerBrowser::GenerateToken(const NETADDR &Addr) const
326333
{
327334
SHA256_CTX Sha256;
@@ -573,10 +580,10 @@ void CServerBrowser::Filter()
573580
}
574581
}
575582

583+
UpdateServerFriends(&Info);
584+
576585
if(!Filtered)
577586
{
578-
UpdateServerFriends(&Info);
579-
580587
if(!g_Config.m_BrFilterFriends || Info.m_FriendState != IFriends::FRIEND_NO)
581588
{
582589
m_NumSortedPlayers += Info.m_NumFilteredPlayers;

src/engine/client/serverbrowser.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ class CServerBrowser : public IServerBrowser
262262
void RequestResort() { m_NeedResort = true; }
263263

264264
int NumServers() const override { return m_vpServerlist.size(); }
265+
const CServerInfo *Get(int Index) const override;
265266
int Players(const CServerInfo &Item) const override;
266267
int Max(const CServerInfo &Item) const override;
267268
int NumSortedServers() const override { return m_vSortedServerlist.size(); }

src/engine/client/sound.cpp

Lines changed: 58 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,9 @@ void CSound::Mix(short *pFinalOut, unsigned Frames)
146146
if(Voice.m_Tick == Voice.m_pSample->m_NumFrames)
147147
{
148148
if(Voice.m_Flags & ISound::FLAG_LOOP)
149-
Voice.m_Tick = 0;
149+
{
150+
Voice.m_Tick = Voice.m_pSample->m_LoopStart;
151+
}
150152
else
151153
{
152154
Voice.m_pSample = nullptr;
@@ -324,6 +326,10 @@ void CSound::RateConvert(CSample &Sample) const
324326
}
325327
}
326328

329+
// adjust looping position, note that this is not precise
330+
const double Factor = (double)m_MixingRate / (double)Sample.m_Rate;
331+
Sample.m_LoopStart = std::round(Sample.m_LoopStart * Factor);
332+
327333
// free old data and apply new
328334
free(Sample.m_pData);
329335
Sample.m_pData = pNewData;
@@ -371,15 +377,40 @@ bool CSound::DecodeOpus(CSample &Sample, const void *pData, unsigned DataSize, c
371377
Pos += Read;
372378
}
373379

374-
op_free(pOpusFile);
375-
376380
Sample.m_pData = pSampleData;
377381
Sample.m_NumFrames = Pos;
378382
Sample.m_Rate = 48000;
379383
Sample.m_Channels = NumChannels;
380-
Sample.m_LoopStart = -1;
381-
Sample.m_LoopEnd = -1;
384+
Sample.m_LoopStart = 0;
382385
Sample.m_PausedAt = 0;
386+
387+
const OpusTags *pTags = op_tags(pOpusFile, -1);
388+
if(pTags)
389+
{
390+
for(int i = 0; i < pTags->comments; ++i)
391+
{
392+
const char *pComment = pTags->user_comments[i];
393+
if(!pComment)
394+
continue;
395+
if(!str_startswith(pComment, "LOOP_START="))
396+
continue;
397+
int LoopStart = -1;
398+
if(!str_toint(pComment + str_length("LOOP_START="), &LoopStart))
399+
{
400+
log_error("sound/opus", "Invalid LOOP_START tag. Value='%s' Filename='%s'", pComment + str_length("LOOP_START="), pContextName);
401+
break;
402+
}
403+
if(LoopStart < 0 || LoopStart >= Sample.m_NumFrames)
404+
{
405+
log_error("sound/opus", "Tag LOOP_START out of range. Value=%d Min=0 Max=%d Filename='%s'", LoopStart, Sample.m_NumFrames - 1, pContextName);
406+
break;
407+
}
408+
Sample.m_LoopStart = LoopStart;
409+
break;
410+
}
411+
}
412+
413+
op_free(pOpusFile);
383414
}
384415
else
385416
{
@@ -504,8 +535,7 @@ bool CSound::DecodeWV(CSample &Sample, const void *pData, unsigned DataSize, con
504535
Sample.m_NumFrames = NumSamples;
505536
Sample.m_Rate = SampleRate;
506537
Sample.m_Channels = NumChannels;
507-
Sample.m_LoopStart = -1;
508-
Sample.m_LoopEnd = -1;
538+
Sample.m_LoopStart = 0;
509539
Sample.m_PausedAt = 0;
510540

511541
s_pWVBuffer = nullptr;
@@ -790,9 +820,28 @@ void CSound::SetVoiceTimeOffset(CVoiceHandle Voice, float TimeOffset)
790820
bool IsLooping = m_aVoices[VoiceId].m_Flags & ISound::FLAG_LOOP;
791821
uint64_t TickOffset = m_aVoices[VoiceId].m_pSample->m_Rate * TimeOffset;
792822
if(m_aVoices[VoiceId].m_pSample->m_NumFrames > 0 && IsLooping)
793-
Tick = TickOffset % m_aVoices[VoiceId].m_pSample->m_NumFrames;
823+
{
824+
const int LoopStart = m_aVoices[VoiceId].m_pSample->m_LoopStart;
825+
const int NumFrames = m_aVoices[VoiceId].m_pSample->m_NumFrames;
826+
if(TickOffset < static_cast<uint64_t>(NumFrames))
827+
{
828+
// Still in first playthrough
829+
Tick = TickOffset;
830+
}
831+
else
832+
{
833+
// Past first playthrough, wrap within loop section only
834+
const int LoopLength = NumFrames - LoopStart;
835+
if(LoopLength > 0)
836+
Tick = LoopStart + ((TickOffset - NumFrames) % LoopLength);
837+
else
838+
Tick = LoopStart;
839+
}
840+
}
794841
else
795-
Tick = std::clamp(TickOffset, (uint64_t)0, (uint64_t)m_aVoices[VoiceId].m_pSample->m_NumFrames);
842+
{
843+
Tick = std::clamp<uint64_t>(TickOffset, 0, m_aVoices[VoiceId].m_pSample->m_NumFrames);
844+
}
796845

797846
// at least 200msec off, else depend on buffer size
798847
float Threshold = maximum(0.2f * m_aVoices[VoiceId].m_pSample->m_Rate, (float)m_MaxFrames);

src/engine/client/sound.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ struct CSample
2121
int m_Rate;
2222
int m_Channels;
2323
int m_LoopStart;
24-
int m_LoopEnd;
2524
int m_PausedAt;
2625

2726
float TotalTime() const

src/engine/server/main.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,10 @@ int main(int argc, const char **argv)
211211
}
212212

213213
#if defined(CONF_PLATFORM_ANDROID)
214-
#if !defined(ANDROID_PACKAGE_NAME)
215-
#error "ANDROID_PACKAGE_NAME must define the package name when compiling for Android (using underscores instead of dots, e.g. org_example_app)"
214+
#if !defined(ANDROID_PACKAGE_NAME_JNI)
215+
#error "ANDROID_PACKAGE_NAME_JNI must define the package name when compiling for Android (using underscores instead of dots, e.g. org_example_app)"
216216
#endif
217-
// Helpers to force macro expansion else the ANDROID_PACKAGE_NAME macro is not expanded
217+
// Helpers to force macro expansion else the ANDROID_PACKAGE_NAME_JNI macro is not expanded
218218
#define EXPAND_MACRO(x) x
219219
#define JNI_MAKE_NAME(PACKAGE, CLASS, FUNCTION) Java_##PACKAGE##_##CLASS##_##FUNCTION
220220
#define JNI_EXPORTED_FUNCTION(PACKAGE, CLASS, FUNCTION, RETURN_TYPE, ...) \
@@ -233,7 +233,7 @@ std::vector<std::string> FetchAndroidServerCommandQueue()
233233
return vResult;
234234
}
235235

236-
JNI_EXPORTED_FUNCTION(ANDROID_PACKAGE_NAME, NativeServer, runServer, jint, JNIEnv *pEnv, jobject Object, jstring WorkingDirectory, jobjectArray ArgumentsArray)
236+
JNI_EXPORTED_FUNCTION(ANDROID_PACKAGE_NAME_JNI, NativeServer, runServer, jint, JNIEnv *pEnv, jobject Object, jstring WorkingDirectory, jobjectArray ArgumentsArray)
237237
{
238238
// Set working directory to external storage location. This is not possible
239239
// in Java so we pass the intended working directory to the native code.
@@ -268,7 +268,7 @@ JNI_EXPORTED_FUNCTION(ANDROID_PACKAGE_NAME, NativeServer, runServer, jint, JNIEn
268268
return main(vpArguments.size(), vpArguments.data());
269269
}
270270

271-
JNI_EXPORTED_FUNCTION(ANDROID_PACKAGE_NAME, NativeServer, executeCommand, void, JNIEnv *pEnv, jobject Object, jstring Command)
271+
JNI_EXPORTED_FUNCTION(ANDROID_PACKAGE_NAME_JNI, NativeServer, executeCommand, void, JNIEnv *pEnv, jobject Object, jstring Command)
272272
{
273273
const char *pCommand = pEnv->GetStringUTFChars(Command, nullptr);
274274
{

src/engine/serverbrowser.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ class IServerBrowser : public IInterface
346346
virtual int LoadingProgression() const = 0;
347347

348348
virtual int NumServers() const = 0;
349+
virtual const CServerInfo *Get(int Index) const = 0;
349350

350351
virtual int Players(const CServerInfo &Item) const = 0;
351352
virtual int Max(const CServerInfo &Item) const = 0;

0 commit comments

Comments
 (0)