0
0

I don’t know is this the right place to ask, but have no idea how to fix the bugs :/. I’m scripter for The Chosen One mod ([url:17jjvcv6]http://www.hellscrag.net/phpBB2/viewtopic.php?t=933[/url:17jjvcv6] and [url:17jjvcv6]http://tcn.unreal.pl[/url:17jjvcv6]) and I started to write mp3 (and ogg) player using fmod.dll. After many errors I finally was able to compile .dll and .u files. But the problem is, that when I run this script, UT crashes with this error:

[quote:17jjvcv6]Critical: appError called:
Critical: Mp3PlayerController 22.Mp3PlayerController0 (Function CHMp3Player.Mp3PlayerController.BeginPlay:0005) Unknown code token AC
Critical: Windows GetLastError: Operacja zakończona pomyślnie. (0)
Exit: Executing UObject::StaticShutdownAfterError
Exit: Executing UWindowsClient::ShutdownAfterError[/quote:17jjvcv6]

EDIT:

Error occures function MusicSystemInit() in CHMp3Player.cpp

And you have to know that I’m native (c++) n00b. So Here is zipped script: [url:17jjvcv6]http://turniej.unreal.pl/files/CHMp3Player.zip[/url:17jjvcv6]

PS. I’m using Visual C++ 6.0.

Mp3Player.uc
[code:17jjvcv6]
class Mp3Player extends Actor
native;

var string Directory;

native(2220) final function bool MusicSystemInit();
native(2321) final function PlaySong(string title);
native(2422) final function StopSong(string title);
native(2523) final function ChangeVolume(int Volume);
native(2624) final function PlayNewSong(string title, string oldtitle);
native(2725) final function ShutDown();

defaultproperties
{
Directory="../mp3/"
}[/code:17jjvcv6]

CHMp3PlayerController.uc
[code:17jjvcv6]
class Mp3PlayerController extends Actor;

exec TEXTURE IMPORT NAME=empeP FILE="textures\Icons\mp3t.bmp" GROUP=Icons LODSET=2

exec OBJ LOAD FILE="..\Music\NoMusic.umx" PACKAGE=NoMusic

var(Mp3Player_Advanced) music SilentSong;
var(Mp3Player_Advanced) string MusicDirectory;
var(Mp3Player_Advanced) class<Mp3Player> MyMp3Player;
var(Mp3Player) bool bPlayOnStart;
var(Mp3Player) bool bMuteModMusic;
var(Mp3Player) string Song;
var(Mp3Player) string OldSong;
var(Mp3Player) enum EAction
{
AC_Stop,
AC_Play,
AC_Switch,
AC_ShutDown
} Action;
var(Mp3Player) int Volume;
var bool bIsInitialized;
var PlayerPawn PlayerInstigator;
var Mp3Player JukeBox;

function BeginPlay()
{
log("Mp3 BEGINPLAY");
JukeBox = Spawn(MyMp3Player,,,Location);
log("Mp3 JukeBox initialized");
if(JukeBox.MusicSystemInit()) //here is god damn error :/
bIsInitialized=true;
log("Mp3 bIsInitialized="$bIsInitialized);
if(!bIsInitialized)
return;
log("Mp3 VolumeControll");
JukeBox.ChangeVolume(Volume);
log("Mp3 VolumeControll passed");
if(Song != "")
{
log("Mp3 InSong");
if(bPlayOnStart)
{
log("Mp3 InPlay");
if(MusicDirectory != "")
JukeBox.Directory=MusicDirectory;
log("Mp3 PlaySOng");
JukeBox.PlaySong(Song);
log("Mp3 PlaySongPassed");
}
}
}
//Sets Action
function SetAction()
{

switch Action
{
case AC_Stop:
JukeBox.StopSong(OldSong);
break;
case AC_Play:
JukeBox.PlaySong(Song);
break;
case AC_Switch:
JukeBox.PlayNewSong(Song, OldSong);
break;
case AC_ShutDown:
JukeBox.ShutDown();
break;
}
}
//Disable music
function CheckForMusic()
{
PlayerInstigator.ClientSetMusic(SilentSong, 0, 255, MTRAN_Fade);
}

function Trigger( actor Other, pawn EventInstigator )
{
if(!bIsInitialized)
return;

  if(MusicDirectory != &quot;&quot;)
        JukeBox.Directory=MusicDirectory;
  if(Song != &quot;&quot;)
  {
        PlayerInstigator=PlayerPawn(EventInstigator);
        if(bMuteModMusic)
           CheckForMusic();
        JukeBox.ChangeVolume(Volume);
        SetAction();
  }

}

defaultproperties
{
DrawType=DT_Sprite
bHidden=true
Texture=Texture’CHMp3Player.Icons.empeP’
SilentSong=music’NoMusic.null’
MusicDirectory="../Music/"
bPlayOnStart=false
bMuteModMusic=true
MyMp3Player=class’CHMp3Player.Mp3Player’
Volume=129
}[/code:17jjvcv6]

CHMp3PlayerPrivate.h
[code:17jjvcv6]/================================================================================
file: CHMp3PlayerPrivate.h
author: Raven
description:
This is private headers for Mp3Player.cpp. Defines basic operations.
================================================================================
/

/——————————————————————————–
IMPORTANT!!
engine and core implementation
——————————————————————————–
/

include "Engine.h"

include "Core.h"

/——————————————————————————–
If you forget this You will have error like this:
‘(...) inconsistent dll linkage. dllexport assumed.(...)’
——————————————————————————–
/

define CHMP3PLAYER_API DLL_EXPORT

/——————————————————————————–
IMPORTANT!!
UCC generated header implementation
This file was created to glue UnrealScript and C++ code together
——————————————————————————–
/

include "CHMp3PlayerClasses.h"

/——————————————————————————–
IMPORTANT!!
fmod implementation. This files allow me to play mp3’s and ogg’s :)
——————————————————————————–
/

include "fmod.h"

include "fmod_errors.h"

/——————————————————————————–
The End.
——————————————————————————–
/[/code:17jjvcv6]

CHMp3Player.cpp
[code:17jjvcv6]
/=====================================================================================
file: Mp3Player.cpp
author: Raven
description:
Main code of mp3 player for The Chosen One modification (my first native class:P.
If you mess something in here leave me as an author :).
=====================================================================================
/

include "CHMp3PlayerPrivate.h"

//package implementation
IMPLEMENT_PACKAGE(CHMp3Player);

void AMp3Player::execMusicSystemInit(FFrame &Stack, /RESULT_DECL/void* Result)
{
guard(AMp3Player::execMusicSystemInit);
P_FINISH;

debugf(NAME_Init, TEXT(&quot;Mp3Player native: bool declataration and Fsound version&quot;));

bool res;
if (FSOUND_GetVersion() &lt; FMOD_VERSION)
{
    res = false;
}
else
{
    res = true;
}

#if defined(WIN32) || defined(_WIN64) || defined(__CYGWIN32__) || defined(__WATCOMC__)

// FSOUND_SetOutput(FSOUND_OUTPUT_WINMM);
FSOUND_SetOutput(FSOUND_OUTPUT_DSOUND);
#elif defined(linux)
FSOUND_SetOutput(FSOUND_OUTPUT_OSS);
#endif

debugf(NAME_Init, TEXT(&quot;Mp3Player native: init sound&quot;));

if (!FSOUND_Init(32000, 64, 0))
{
    res = false;
    FSOUND_Close();
}
else
{
    res = true;
}

FSOUND_SetDriver(0);
FSOUND_Stream_SetBufferSize(1000);

debugf(NAME_Init, TEXT(&quot;Mp3Player native: System check&quot;));

debugf(NAME_Init, TEXT(&quot;Mp3Player native: returning value&quot;));

// To understand exactly how this works, you need to know about pointers
*(UBOOL*)Result = res;

debugf(NAME_Init, TEXT(&quot;Mp3Player native: unguard&quot;));

unguard;

}

void AMp3Player::execPlaySong( FFrame &Stack, void* Result)
{
guard(AMp3Player::execPlaySong);
P_GET_STR( title );
P_GET_STR_REF( directory );
P_FINISH;

FSOUND_STREAM *stream;
char *tit;

tit=(char *)directory+title;

stream = FSOUND_Stream_Open(tit, FSOUND_LOOP_NORMAL, 0, 0);
FSOUND_Stream_Play(1, stream);

unguard;

}
void AMp3Player::execStopSong( FFrame &Stack, void* Result)
{
guard(AMp3Player::execPlaySong);
P_GET_STR( title );
P_GET_STR_REF( directory );
P_FINISH;

FSOUND_STREAM *stream;
char *tit;

tit=(char *)directory+title;

stream = FSOUND_Stream_Open(tit, FSOUND_LOOP_NORMAL, 0, 0);
FSOUND_Stream_Play(1, stream);

unguard;

}

void AMp3Player::execChangeVolume( FFrame &Stack, void* Result)
{
guard(AMp3Player::execChangeVolume);
P_GET_INT( Volume );
P_FINISH;

FSOUND_SetVolume(1, Volume);

unguard;

}

void AMp3Player::execPlayNewSong( FFrame &Stack, void* Result)
{
guard(AMp3Player::execPlaySong);
P_GET_STR( title );
P_GET_STR( old_title );
P_GET_STR_REF( directory );
P_FINISH;

FSOUND_STREAM *stream;
FSOUND_STREAM *stream1;
char *tit;
char *old;

old=(char *)directory+old_title;
stream1 = FSOUND_Stream_Open(old, FSOUND_LOOP_NORMAL, 0, 0);
FSOUND_Stream_Close(stream1);

tit=(char *)directory+title;
stream = FSOUND_Stream_Open(tit, FSOUND_LOOP_NORMAL, 0, 0);
FSOUND_Stream_Play(1, stream);

unguard;

}

void AMp3Player::execShutdown( FFrame &Stack, void* Result){ ; }

//class implementation
IMPLEMENT_CLASS(AMp3Player);
[/code:17jjvcv6]

UCC generated header is not important :). Please someone help me, I don’t know what to make this work :(.

  • You must to post comments
0
0

Error was occurred by code that “wasn’t needed” :). So I finally was able to run this without UT crash. But anyway stream doesn’t play :(. Maybe it’s fault of my code:

[code:2doxkmyw]
void AMp3Player::execPlaySong( FFrame &Stack, void* Result)
{
guard(AMp3Player::execPlaySong);
P_GET_STR( title );
P_GET_STR_REF( directory );
P_FINISH;

FSOUND_STREAM *stream; 
char *tit; 

tit=(char *)directory+title; 

stream = FSOUND_Stream_Open(tit, FSOUND_LOOP_NORMAL, 0, 0); 
FSOUND_Stream_Play(1, stream); 

unguard; 

}
[/code:2doxkmyw]

  • You must to post comments
0
0

THX for the info. I’ll be gone for a few weeks, so I will not have my computer to checkt it :(.

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.