From c3cf1b6d440c04349d0d289ff0da3111ce34e878 Mon Sep 17 00:00:00 2001 From: Positron Date: Fri, 9 Dec 2016 01:16:09 -0500 Subject: [PATCH] Update example files --- test/bigint.bcs | 16 ++++++++-------- test/functions.bcs | 16 ++++++++-------- test/jm.bcs | 33 ++++++++++++++++----------------- test/jm_header/map_message.bcs | 10 ++++------ test/jm_header/solo_ranker.bcs | 8 ++++---- test/jm_header/svmz.bcs | 10 +++++----- test/jm_header/team_ranker.bcs | 12 ++++++------ test/sorting.bcs | 4 ++-- 8 files changed, 53 insertions(+), 56 deletions(-) diff --git a/test/bigint.bcs b/test/bigint.bcs index feb68d54..8dd50ec9 100644 --- a/test/bigint.bcs +++ b/test/bigint.bcs @@ -28,9 +28,9 @@ typeaware blockscoping namespace BigInt { // ========================================================================== str Add( str a, str b ) { - return StrParam( msgbuild: { + return StrParam( msgbuild: ( function msgbuild { // Calculate sum. - str sum = StrParam( msgbuild: { + str sum = StrParam( msgbuild: ( function msgbuild { int i_a = a.length() - 1; int i_b = b.length() - 1; int carry = 0; @@ -43,18 +43,18 @@ str Add( str a, str b ) { --i_b; } append( c: carry * '1' ); - } ); + } ) ); // Output sum. int i = sum.length() - 1; while ( i >= 0 ) { append( c: sum[ i ] ); --i; } - } ); + } ) ); } str Sub( str a, str b ) { - return StrParam( msgbuild: { + return StrParam( msgbuild: ( function msgbuild { // Negative. if ( Lt( a, b ) ) { append( c: '-' ); @@ -63,7 +63,7 @@ str Sub( str a, str b ) { b = temp_a; } // Calculate difference. - str diff = StrParam( msgbuild: { + str diff = StrParam( msgbuild: ( function msgbuild { int i_a = a.length() - 1; int i_b = b.length() - 1; int borrow = 0; @@ -76,7 +76,7 @@ str Sub( str a, str b ) { --i_a; --i_b; } - } ); + } ) ); // Output difference. int i = diff.length() - 1; while ( i >= 1 && diff[ i ] == '0' ) { @@ -86,7 +86,7 @@ str Sub( str a, str b ) { append( c: diff[ i ] ); --i; } - } ); + } ) ); } bool Lt( str a, str b ) { diff --git a/test/functions.bcs b/test/functions.bcs index a8ba7adc..2bd9878b 100644 --- a/test/functions.bcs +++ b/test/functions.bcs @@ -36,7 +36,7 @@ int StriCmp( str a, str b, int length = -1 ) { // Get substring. str StrMid( str string, int start, int length ) { - return StrParam( msgbuild: { + return StrParam( msgbuild: ( function msgbuild { if ( start < 0 ) { start = 0; } @@ -47,7 +47,7 @@ str StrMid( str string, int start, int length ) { append( c: c ); ++i; } - } ); + } ) ); } // Get substring, starting at offset 0. @@ -62,7 +62,7 @@ str StrRight( str string, int length ) { // Get string as uppercase. Character encoding assumed to be ASCII. str StrToUpper( str string ) { - return StrParam( msgbuild: { + return StrParam( msgbuild: ( function msgbuild { foreach ( auto ch; string ) { if ( ch >= 97 && ch <= 122 ) { append( c: ch - 32 ); @@ -71,12 +71,12 @@ str StrToUpper( str string ) { append( c: ch ); } } - } ); + } ) ); } // Get string as lowercase. str StrToLower( str string ) { - return StrParam( msgbuild: { + return StrParam( msgbuild: ( function msgbuild { foreach ( auto ch; string ) { if ( ch >= 65 && ch <= 90 ) { append( c: ch + 32 ); @@ -85,14 +85,14 @@ str StrToLower( str string ) { append( c: ch ); } } - } ); + } ) ); } // Supports up to 10 arguments, integer or string. void Printf( str format, raw arg1 = 0, raw arg2 = 0, raw arg3 = 0, raw arg4 = 0, raw arg5 = 0, raw arg6 = 0, raw arg7 = 0, raw arg8 = 0, raw arg9 = 0, raw arg10 = 0 ) { - Print( msgbuild: { + Print( msgbuild: ( function msgbuild { int num = 0; int pos = 0; while ( num < 10 ) { @@ -140,7 +140,7 @@ void Printf( str format, raw arg1 = 0, raw arg2 = 0, raw arg3 = 0, ++num; } done: - } ); + } ) ); } } \ No newline at end of file diff --git a/test/jm.bcs b/test/jm.bcs index 31140c15..b3cdb5f3 100644 --- a/test/jm.bcs +++ b/test/jm.bcs @@ -417,7 +417,7 @@ script 980 enter { private function void Show() { SetFont( "SMALLFONT" ); - HudMessage( msgbuild: { + HudMessage( msgbuild: ( function msgbuild { append( s: "\cf", s: gName, s: " - ", s: "MAP", s: Jm.Utility.ZeroPad( gNumber ), @@ -437,20 +437,19 @@ private function void Show() { s: SoloRanker.GetHsAuthorName() ); } - }; HUDMSG_FADEOUT | HUDMSG_LOG, 412, 0, 1.5, 0.3, DISPLAY_TIME, - 1.0 ); + } ); HUDMSG_FADEOUT | HUDMSG_LOG, 412, 0, 1.5, 0.3, DISPLAY_TIME, 1.0 ); } // Removes the whitespace found in the par time, so it looks nicer when shown // in the map message. private function void SetPar( str par ) { - gPar = StrParam( msgbuild: { + gPar = StrParam( msgbuild: ( function msgbuild { foreach ( int ch; par ) { if ( ch != ' ' ) { append( c: ch ); } } - } ); + } ) ); } } @@ -1136,7 +1135,7 @@ script "SoloRanker.ClientQuit" ( int player ) disconnect { private function void ShowTable() { SetFont( "SMALLFONT" ); - HudMessageBold( msgbuild: { + HudMessageBold( msgbuild: ( function msgbuild { if ( Hs.IsSet() ) { DrawHsTime(); append( s: "\n" ); @@ -1163,7 +1162,7 @@ private function void ShowTable() { s: ZeroPad( spot.centiseconds ), d: spot.centiseconds, s: "\n\n" ); } - }; HUDMSG_PLAIN, TBL_LINEID, 0, TBL_X, TBL_Y, 0.0 ); + } ); HUDMSG_PLAIN, TBL_LINEID, 0, TBL_X, TBL_Y, 0.0 ); } private function void ClearTable() { @@ -1172,7 +1171,7 @@ private function void ClearTable() { private function void ShowIndividualTime( int tics ) { SetFont( "SMALLFONT" ); - HudMessage( msgbuild: { + HudMessage( msgbuild: ( function msgbuild { for ( auto i = 0; i < RANK_LIMIT_MAX; ++i ) { append( s: "\n" ); } @@ -1183,7 +1182,7 @@ private function void ShowIndividualTime( int tics ) { s: ZeroPad( minutes ), d: minutes, s: ":", s: ZeroPad( seconds ), d: seconds, s: "\cu.", s: ZeroPad( centiseconds ), d: centiseconds ); - }; HUDMSG_PLAIN, INDI_TIME_LINEID, 0, TBL_X, TBL_Y , 0.0 ); + } ); HUDMSG_PLAIN, INDI_TIME_LINEID, 0, TBL_X, TBL_Y , 0.0 ); } private function void ClearIndividualTime() { @@ -1422,7 +1421,7 @@ script 961 ( int player ) disconnect { private function void ShowTable() { SetFont( "SMALLFONT" ); - HudMessageBold( msgbuild: { + HudMessageBold( msgbuild: ( function msgbuild { if ( Hs.IsSet() ) { DrawHsTime(); append( s: "\n\n" ); @@ -1442,7 +1441,7 @@ private function void ShowTable() { d: gTable.spots[ i ].points ); } } - }; HUDMSG_PLAIN, TBL_LINEID_OFFSET, 0, TBL_X, TBL_Y, 0.0 ); + } ); HUDMSG_PLAIN, TBL_LINEID_OFFSET, 0, TBL_X, TBL_Y, 0.0 ); } private function msgbuild void DrawTime() { @@ -1460,7 +1459,7 @@ private function msgbuild void DrawTime() { private function void ShowGoals() { SetFont( "SMALLFONT" ); - HudMessage( msgbuild: { + HudMessage( msgbuild: ( function msgbuild { if ( gPointsLeft == 0 ) { DrawTime(); } @@ -1477,7 +1476,7 @@ private function void ShowGoals() { // always one place taken in the score table, which will be the first. d: gTable.spots[ 0 ].points, s: labelColor, s: " / ", s: totalColor, d: gPointsTotal ); - }; HUDMSG_PLAIN, TBL_LINEID_OFFSET, 0, TBL_X, TBL_Y, 0.0 ); + } ); HUDMSG_PLAIN, TBL_LINEID_OFFSET, 0, TBL_X, TBL_Y, 0.0 ); } function void ClearPointsTable() { @@ -1620,7 +1619,7 @@ private function void AnnounceCheat() { // Prints high score details table. script "TeamRanker.ShowHs" ( raw showTime ) { SetFont( "SMALLFONT" ); - HudMessage( msgbuild: { + HudMessage( msgbuild: ( function msgbuild { append( s: "\ciRecord details", s: "\n\n", s: "\ckDate Set:", s: "\n", s: "\cc", s: Utility.GetMonthName( gHsMonth ), s: " ", d: gHsDay, s: ", ", d: gHsYear, s: "\n\n", s: "\ckFinish Time:", s: "\n", @@ -1635,7 +1634,7 @@ script "TeamRanker.ShowHs" ( raw showTime ) { if ( gHsUnaccountedPoints > 0 ) { append( s: "\cgUnaccounted \cd", d: gHsUnaccountedPoints ); } - }; HUDMSG_FADEOUT, HS_TBL_LINE, 0, HS_TBL_X, HS_TBL_Y, showTime, 1.0 ); + } ); HUDMSG_FADEOUT, HS_TBL_LINE, 0, HS_TBL_X, HS_TBL_Y, showTime, 1.0 ); } function void PrepareForSvmz() { @@ -2313,7 +2312,7 @@ function void DisplayMinEscapeesFail() { function void DisplayEscapeeStats() { SetFont( "SMALLFONT" ); - HudMessageBold( msgbuild: { + HudMessageBold( msgbuild: ( function msgbuild { auto minEscapees = GetMinEscapees(); auto numEscapees = Escapee.GetCount(); // Change the color of the statistic to green to indicate success. @@ -2325,7 +2324,7 @@ function void DisplayEscapeeStats() { append( s: "\ccEscapees: \ck", d: numEscapees, s: "\cc / \ci", d: minEscapees ); } - }; HUDMSG_PLAIN, LINE_STATS, 0, 1.5, 0.05, 0.0 ); + } ); HUDMSG_PLAIN, LINE_STATS, 0, 1.5, 0.05, 0.0 ); } private function int GetNumAlive() { diff --git a/test/jm_header/map_message.bcs b/test/jm_header/map_message.bcs index 433e801b..69466f7e 100644 --- a/test/jm_header/map_message.bcs +++ b/test/jm_header/map_message.bcs @@ -1,4 +1,3 @@ - #if 1 #library "mapmsg" @@ -71,7 +70,7 @@ script "MapMsg.Show" enter { private void Show() { SetFont( "SMALLFONT" ); - HudMessage( msgbuild: { + HudMessage( msgbuild: ( function msgbuild { append( s: "\cf", s: gName, s: " - ", s: "MAP", s: Jm.Utility.ZeroPad( gNumber ), @@ -91,20 +90,19 @@ private void Show() { s: SoloRanker.GetHsAuthorName() ); } - }; HUDMSG_FADEOUT | HUDMSG_LOG, 412, 0, 1.5, 0.3, DISPLAY_TIME, - 1.0 ); + } ); HUDMSG_FADEOUT | HUDMSG_LOG, 412, 0, 1.5, 0.3, DISPLAY_TIME, 1.0 ); } // Removes the whitespace found in the par time, so it looks nicer when shown // in the map message. private void SetPar( str par ) { - gPar = StrParam( msgbuild: { + gPar = StrParam( msgbuild: ( function msgbuild { foreach ( int ch; par ) { if ( ch != ' ' ) { append( c: ch ); } } - } ); + } ) ); } } diff --git a/test/jm_header/solo_ranker.bcs b/test/jm_header/solo_ranker.bcs index 201c940c..7e856a87 100644 --- a/test/jm_header/solo_ranker.bcs +++ b/test/jm_header/solo_ranker.bcs @@ -156,7 +156,7 @@ script "SoloRanker.ClientQuit" ( int player ) disconnect { private void ShowTable() { SetFont( "SMALLFONT" ); - HudMessageBold( msgbuild: { + HudMessageBold( msgbuild: ( function msgbuild { if ( Hs.IsSet() ) { DrawHsTime(); append( s: "\n" ); @@ -183,7 +183,7 @@ private void ShowTable() { s: ZeroPad( spot.centiseconds ), d: spot.centiseconds, s: "\n\n" ); } - }; HUDMSG_PLAIN, TBL_LINEID, 0, TBL_X, TBL_Y, 0.0 ); + } ); HUDMSG_PLAIN, TBL_LINEID, 0, TBL_X, TBL_Y, 0.0 ); } private void ClearTable() { @@ -192,7 +192,7 @@ private void ClearTable() { private void ShowIndividualTime( int tics ) { SetFont( "SMALLFONT" ); - HudMessage( msgbuild: { + HudMessage( msgbuild: ( function msgbuild { for ( auto i = 0; i < RANK_LIMIT_MAX; ++i ) { append( s: "\n" ); } @@ -203,7 +203,7 @@ private void ShowIndividualTime( int tics ) { s: ZeroPad( minutes ), d: minutes, s: ":", s: ZeroPad( seconds ), d: seconds, s: "\cu.", s: ZeroPad( centiseconds ), d: centiseconds ); - }; HUDMSG_PLAIN, INDITIME_LINEID, 0, TBL_X, TBL_Y , 0.0 ); + } ); HUDMSG_PLAIN, INDITIME_LINEID, 0, TBL_X, TBL_Y , 0.0 ); } private void ClearIndividualTime() { diff --git a/test/jm_header/svmz.bcs b/test/jm_header/svmz.bcs index 3c822c83..9d07b9fc 100644 --- a/test/jm_header/svmz.bcs +++ b/test/jm_header/svmz.bcs @@ -289,7 +289,7 @@ void DisplayMinEscapeesFail() { void DisplayEscapeeStats() { SetFont( "SMALLFONT" ); - HudMessageBold( msgbuild: { + HudMessageBold( msgbuild: ( function msgbuild { auto minEscapees = GetMinEscapees(); auto numEscapees = Escapee.GetCount(); // Change the color of the statistic to green to indicate success. @@ -301,7 +301,7 @@ void DisplayEscapeeStats() { append( s: "\ccEscapees: \ck", d: numEscapees, s: "\cc / \ci", d: minEscapees ); } - }; HUDMSG_PLAIN, LINE_STATS, 0, 1.5, 0.05, 0.0 ); + } ); HUDMSG_PLAIN, LINE_STATS, 0, 1.5, 0.05, 0.0 ); } private int GetNumAlive() { @@ -315,7 +315,7 @@ private int GetNumAlive() { } // ========================================================================== -namespace Jm.Svmz.Escapee { +typeaware blockscoping namespace Jm.Svmz.Escapee { // ========================================================================== using upmost; @@ -350,7 +350,7 @@ int GetCount() { } // ========================================================================== -namespace Jm.Svmz.Timer { +typeaware blockscoping namespace Jm.Svmz.Timer { // ========================================================================== using upmost; @@ -412,7 +412,7 @@ script 908 { } // ========================================================================== -namespace Jm.Svmz.Item { +typeaware blockscoping namespace Jm.Svmz.Item { // ========================================================================== using upmost; diff --git a/test/jm_header/team_ranker.bcs b/test/jm_header/team_ranker.bcs index 109cc776..c80299f2 100644 --- a/test/jm_header/team_ranker.bcs +++ b/test/jm_header/team_ranker.bcs @@ -129,7 +129,7 @@ script "TeamRanker.ClientQuit" ( int player ) disconnect { private void ShowTable() { SetFont( "SMALLFONT" ); - HudMessageBold( msgbuild: { + HudMessageBold( msgbuild: ( function msgbuild { if ( Hs.IsSet() ) { DrawHsTime(); append( s: "\n\n" ); @@ -149,7 +149,7 @@ private void ShowTable() { d: gTable.spots[ i ].points ); } } - }; HUDMSG_PLAIN, TBL_LINEID_OFFSET, 0, TBL_X, TBL_Y, 0.0 ); + } ); HUDMSG_PLAIN, TBL_LINEID_OFFSET, 0, TBL_X, TBL_Y, 0.0 ); } private msgbuild void DrawTime() { @@ -167,7 +167,7 @@ private msgbuild void DrawTime() { private void ShowGoals() { SetFont( "SMALLFONT" ); - HudMessage( msgbuild: { + HudMessage( msgbuild: ( function msgbuild { if ( gPointsLeft == 0 ) { DrawTime(); } @@ -184,7 +184,7 @@ private void ShowGoals() { // always one place taken in the score table, which will be the first. d: gTable.spots[ 0 ].points, s: labelColor, s: " / ", s: totalColor, d: gPointsTotal ); - }; HUDMSG_PLAIN, TBL_LINEID_OFFSET, 0, TBL_X, TBL_Y, 0.0 ); + } ); HUDMSG_PLAIN, TBL_LINEID_OFFSET, 0, TBL_X, TBL_Y, 0.0 ); } void ClearPointsTable() { @@ -326,7 +326,7 @@ private void AnnounceCheat() { // Prints high score details table. script "TeamRanker.ShowHs" ( raw showTime ) { SetFont( "SMALLFONT" ); - HudMessage( msgbuild: { + HudMessage( msgbuild: ( function msgbuild { append( s: "\ciRecord details", s: "\n\n", s: "\ckDate Set:", s: "\n", s: "\cc", s: Utility.GetMonthName( gHsMonth ), s: " ", d: gHsDay, s: ", ", d: gHsYear, s: "\n\n", s: "\ckFinish Time:", s: "\n", @@ -341,7 +341,7 @@ script "TeamRanker.ShowHs" ( raw showTime ) { if ( gHsUnaccountedPoints > 0 ) { append( s: "\cgUnaccounted \cd", d: gHsUnaccountedPoints ); } - }; HUDMSG_FADEOUT, HS_TBL_LINE, 0, HS_TBL_X, HS_TBL_Y, showTime, 1.0 ); + } ); HUDMSG_FADEOUT, HS_TBL_LINE, 0, HS_TBL_X, HS_TBL_Y, showTime, 1.0 ); } void PrepareForSvmz() { diff --git a/test/sorting.bcs b/test/sorting.bcs index 11fce0f6..986568c0 100644 --- a/test/sorting.bcs +++ b/test/sorting.bcs @@ -10,7 +10,7 @@ script "Main" open { for ( int i = 0; i < list.length(); ++i ) { list[ i ] = Random( 1, 9 ); } - Print( msgbuild: { + Print( msgbuild: ( function msgbuild { // Unsorted: Append( s: "Unsorted:" ); foreach ( auto value; list ) { @@ -27,7 +27,7 @@ script "Main" open { foreach ( auto value; list ) { Append( s: " ", d: value ); } - } ); + } ) ); } // Bubble sort.