fixed some special-case crashes in the editor. also some other small things.

This commit is contained in:
Erik Faye-Lund 2008-02-16 02:34:02 +00:00
parent fcf160d917
commit e04c3aa08c
7 changed files with 428 additions and 53 deletions

View File

@ -647,7 +647,7 @@ LRESULT TrackView::onHScroll(UINT sbCode, int /*newPos*/)
void TrackView::editEnterValue()
{
if (editString.size() > 0)
if (int(editString.size()) > 0 && editTrack < int(syncData->getTrackCount()))
{
sync::Track &t = syncData->getTrack(editTrack);
@ -671,6 +671,12 @@ void TrackView::editDelete()
int selectTop = min(selectStartRow, selectStopRow);
int selectBottom = max(selectStartRow, selectStopRow);
if (selectRight >= int(syncData->getTrackCount()))
{
MessageBeep(0);
return;
}
SyncEditData::MultiCommand *multiCmd = new SyncEditData::MultiCommand();
for (int track = selectLeft; track <= selectRight; ++track)
{
@ -782,9 +788,6 @@ LRESULT TrackView::onKeyDown(UINT keyCode, UINT /*flags*/)
}
else setEditRow(editRow + windowRows / 2);
break;
default:
break;
}
}
@ -813,6 +816,12 @@ LRESULT TrackView::onKeyDown(UINT keyCode, UINT /*flags*/)
}
break;
case VK_SPACE:
if (!editString.empty())
{
editString.clear();
invalidatePos(editTrack, editRow);
MessageBeep(0);
}
getSyncData()->sendPauseCommand( !getSyncData()->clientPaused );
break;
}
@ -823,13 +832,6 @@ LRESULT TrackView::onChar(UINT keyCode, UINT flags)
{
switch (char(keyCode))
{
case '.':
// only one '.' allowed
if (std::string::npos != editString.find('.'))
{
MessageBeep(0);
break;
}
case '-':
if (editString.empty())
{
@ -837,7 +839,13 @@ LRESULT TrackView::onChar(UINT keyCode, UINT flags)
invalidatePos(editTrack, editRow);
}
break;
case '.':
// only one '.' allowed
if (std::string::npos != editString.find('.'))
{
MessageBeep(0);
break;
}
case '0':
case '1':
case '2':
@ -848,8 +856,12 @@ LRESULT TrackView::onChar(UINT keyCode, UINT flags)
case '7':
case '8':
case '9':
editString.push_back(char(keyCode));
invalidatePos(editTrack, editRow);
if (editTrack < int(syncData->getTrackCount()))
{
editString.push_back(char(keyCode));
invalidatePos(editTrack, editRow);
}
else MessageBeep(0);
break;
}
return FALSE;

View File

@ -55,11 +55,11 @@ int main(int argc, char *argv[])
if (!BASS_Init(soundDevice, 44100, BASS_DEVICE_LATENCY, 0, 0)) throw std::string("failed to init bass");
// load tune
HSTREAM stream = BASS_StreamCreateFile(false, "tune.mp3", 0, 0, BASS_MP3_SETPOS | ((0 == soundDevice) ? BASS_STREAM_DECODE : 0));
HSTREAM stream = BASS_StreamCreateFile(false, "tune.ogg", 0, 0, BASS_MP3_SETPOS | ((0 == soundDevice) ? BASS_STREAM_DECODE : 0));
if (!stream) throw std::string("failed to open tune");
// setup timer and construct sync-device
BassTimer timer(stream, 120.0f, 4);
BassTimer timer(stream, 150.0f, 4);
std::auto_ptr<sync::Device> syncDevice = std::auto_ptr<sync::Device>(sync::createDevice("sync", timer));
if (NULL == syncDevice.get()) throw std::string("something went wrong - failed to connect to host?");

View File

@ -60,7 +60,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="d3dx9.lib d3d9.lib ws2_32.lib"
AdditionalDependencies="d3dx9.lib d3d9.lib"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="1"
@ -134,6 +134,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="d3dx9.lib d3d9.lib"
LinkIncremental="1"
GenerateDebugInformation="true"
SubSystem="1"
@ -176,25 +177,9 @@
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath="..\sync\data.cpp"
>
</File>
<File
RelativePath="..\sync\device_client.cpp"
>
</File>
<File
RelativePath=".\example_bass.cpp"
>
</File>
<File
RelativePath="..\sync\network.cpp"
>
</File>
<File
RelativePath="..\sync\track.cpp"
>
</File>
</Filter>
<Filter
Name="Header Files"

View File

@ -40,20 +40,19 @@ Track &ClientDevice::getTrack(const std::string &trackName)
unsigned char cmd = GET_TRACK;
send(serverSocket, (char*)&cmd, 1, 0);
size_t clientIndex = syncData.actualTracks.size();
send(serverSocket, (char*)&clientIndex, sizeof(size_t), 0);
// send request data
size_t name_len = trackName.size();
printf("len: %d\n", name_len);
send(serverSocket, (char*)&name_len, sizeof(size_t), 0);
const char *name_str = trackName.c_str();
send(serverSocket, name_str, int(name_len), 0);
sync::Track *track = new sync::Track();
syncData.actualTracks.push_back(track);
syncData.tracks[trackName] = clientIndex;
return *track;
@ -83,7 +82,6 @@ bool ClientDevice::update(float row)
recv(serverSocket, (char*)&track, sizeof(int), 0);
recv(serverSocket, (char*)&row, sizeof(int), 0);
recv(serverSocket, (char*)&value, sizeof(float), 0);
printf("set: %d,%d = %f\n", track, row, value);
sync::Track &t = syncData.getTrack(track);
t.setKeyFrame(row, Track::KeyFrame(value));
@ -95,7 +93,6 @@ bool ClientDevice::update(float row)
int track, row;
recv(serverSocket, (char*)&track, sizeof(int), 0);
recv(serverSocket, (char*)&row, sizeof(int), 0);
printf("delete: %d,%d\n", track, row);
sync::Track &t = syncData.getTrack(track);
t.deleteKeyFrame(row);
@ -106,7 +103,6 @@ bool ClientDevice::update(float row)
{
int row;
recv(serverSocket, (char*)&row, sizeof(int), 0);
printf("set row: %d\n", row);
timer.setRow(float(row));
}
break;
@ -115,14 +111,14 @@ bool ClientDevice::update(float row)
{
char flag;
recv(serverSocket, (char*)&flag, 1, 0);
printf("pause: %d\n", flag);
if (flag == 0) timer.play();
else timer.pause();
}
break;
default:
printf("unknown cmd: %02x\n", cmd);
assert(false);
fprintf(stderr, "unknown cmd: %02x\n", cmd);
}
}
}
@ -144,11 +140,7 @@ bool ClientDevice::update(float row)
Device *sync::createDevice(const std::string &baseName, Timer &timer)
{
if (false == initNetwork())
{
printf("noes 1!\n");
return NULL;
}
if (false == initNetwork()) return NULL;
struct hostent *myhost = gethostbyname("localhost");
struct sockaddr_in sain;
@ -158,13 +150,8 @@ Device *sync::createDevice(const std::string &baseName, Timer &timer)
// connect to server
SOCKET serverSocket = serverConnect(&sain);
if (INVALID_SOCKET == serverSocket)
{
printf("noes 2!\n");
return NULL;
}
if (INVALID_SOCKET == serverSocket) return NULL;
Device *device = new ClientDevice(baseName, serverSocket, timer);
return device;
}

View File

@ -34,7 +34,7 @@ Track &PlayerDevice::getTrack(const std::string &trackName)
sync::Track *track = new sync::Track();
// TODO: load data from file
track->setKeyFrame(0, 10.0f);
track->setKeyFrame(0, 1.0f);
track->setKeyFrame(10, 0.0f);
size_t index = syncData.actualTracks.size();

368
sync_player.vcproj Normal file
View File

@ -0,0 +1,368 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8,00"
Name="sync_player"
ProjectGUID="{5866042C-7FCB-4DB1-BAAD-44DF6567511F}"
RootNamespace="sync_player"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="2"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Debug Client|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release Client|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="2"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
AdditionalDependencies="ws2_32.lib"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\sync\data.cpp"
>
</File>
<File
RelativePath=".\sync\device_client.cpp"
>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\sync\device_player.cpp"
>
<FileConfiguration
Name="Debug Client|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Release Client|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\sync\network.cpp"
>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\sync\track.cpp"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\sync\device.h"
>
</File>
<File
RelativePath=".\sync\network.h"
>
</File>
<File
RelativePath=".\sync\track.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -4,21 +4,44 @@ Microsoft Visual Studio Solution File, Format Version 9.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "editor", "editor\editor.vcproj", "{76B44BC8-8BB4-4B6E-B2FA-7738C9E7F80B}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example_bass", "example_bass\example_bass.vcproj", "{96D91AAD-2F45-4CC6-A923-96B80E1C3CE3}"
ProjectSection(ProjectDependencies) = postProject
{5866042C-7FCB-4DB1-BAAD-44DF6567511F} = {5866042C-7FCB-4DB1-BAAD-44DF6567511F}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sync_player", "sync_player.vcproj", "{5866042C-7FCB-4DB1-BAAD-44DF6567511F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug Client|Win32 = Debug Client|Win32
Debug|Win32 = Debug|Win32
Release Client|Win32 = Release Client|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{76B44BC8-8BB4-4B6E-B2FA-7738C9E7F80B}.Debug Client|Win32.ActiveCfg = Debug|Win32
{76B44BC8-8BB4-4B6E-B2FA-7738C9E7F80B}.Debug Client|Win32.Build.0 = Debug|Win32
{76B44BC8-8BB4-4B6E-B2FA-7738C9E7F80B}.Debug|Win32.ActiveCfg = Debug|Win32
{76B44BC8-8BB4-4B6E-B2FA-7738C9E7F80B}.Debug|Win32.Build.0 = Debug|Win32
{76B44BC8-8BB4-4B6E-B2FA-7738C9E7F80B}.Release Client|Win32.ActiveCfg = Release|Win32
{76B44BC8-8BB4-4B6E-B2FA-7738C9E7F80B}.Release Client|Win32.Build.0 = Release|Win32
{76B44BC8-8BB4-4B6E-B2FA-7738C9E7F80B}.Release|Win32.ActiveCfg = Release|Win32
{76B44BC8-8BB4-4B6E-B2FA-7738C9E7F80B}.Release|Win32.Build.0 = Release|Win32
{96D91AAD-2F45-4CC6-A923-96B80E1C3CE3}.Debug Client|Win32.ActiveCfg = Debug|Win32
{96D91AAD-2F45-4CC6-A923-96B80E1C3CE3}.Debug Client|Win32.Build.0 = Debug|Win32
{96D91AAD-2F45-4CC6-A923-96B80E1C3CE3}.Debug|Win32.ActiveCfg = Debug|Win32
{96D91AAD-2F45-4CC6-A923-96B80E1C3CE3}.Debug|Win32.Build.0 = Debug|Win32
{96D91AAD-2F45-4CC6-A923-96B80E1C3CE3}.Release Client|Win32.ActiveCfg = Release|Win32
{96D91AAD-2F45-4CC6-A923-96B80E1C3CE3}.Release Client|Win32.Build.0 = Release|Win32
{96D91AAD-2F45-4CC6-A923-96B80E1C3CE3}.Release|Win32.ActiveCfg = Release|Win32
{96D91AAD-2F45-4CC6-A923-96B80E1C3CE3}.Release|Win32.Build.0 = Release|Win32
{5866042C-7FCB-4DB1-BAAD-44DF6567511F}.Debug Client|Win32.ActiveCfg = Debug Client|Win32
{5866042C-7FCB-4DB1-BAAD-44DF6567511F}.Debug Client|Win32.Build.0 = Debug Client|Win32
{5866042C-7FCB-4DB1-BAAD-44DF6567511F}.Debug|Win32.ActiveCfg = Debug|Win32
{5866042C-7FCB-4DB1-BAAD-44DF6567511F}.Debug|Win32.Build.0 = Debug|Win32
{5866042C-7FCB-4DB1-BAAD-44DF6567511F}.Release Client|Win32.ActiveCfg = Release Client|Win32
{5866042C-7FCB-4DB1-BAAD-44DF6567511F}.Release Client|Win32.Build.0 = Release Client|Win32
{5866042C-7FCB-4DB1-BAAD-44DF6567511F}.Release|Win32.ActiveCfg = Release|Win32
{5866042C-7FCB-4DB1-BAAD-44DF6567511F}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE