@@ -355,13 +355,6 @@ function mergeExploration(
355355 mergeMoveRecursive ( gameEngine , node , data [ 0 ] . tree ) ;
356356 } else if ( data [ 1 ] && data [ 1 ] . move === moveNumber - 1 ) {
357357 let node = exploration [ moveNumber - 1 ] ;
358- // rehydrate state if needed
359- if ( node . state === null ) {
360- let tmpEngine = GameFactory ( game . metaGame , game . state ) ;
361- tmpEngine . stack = tmpEngine . stack . slice ( 0 , moveNumber + 1 ) ;
362- tmpEngine . load ( ) ;
363- node . state = tmpEngine . cheapSerialize ( ) ;
364- }
365358 let gameEngine = GameFactory ( game . metaGame , node . state ) ;
366359 // subtree of the move I chose
367360 const subtree1 = data [ 1 ] . tree . find ( ( e ) =>
@@ -386,13 +379,6 @@ function mergeExploration(
386379 } else if ( data [ 2 ] && data [ 2 ] . move === moveNumber - 2 ) {
387380 console . log ( "Merging 2 moves back" ) ;
388381 let node = exploration [ moveNumber - 2 ] ;
389- // rehydrate state if needed
390- if ( node . state === null ) {
391- let tmpEngine = GameFactory ( game . metaGame , game . state ) ;
392- tmpEngine . stack = tmpEngine . stack . slice ( 0 , moveNumber + 1 ) ;
393- tmpEngine . load ( ) ;
394- node . state = tmpEngine . cheapSerialize ( ) ;
395- }
396382 let gameEngine = GameFactory ( game . metaGame , node . state ) ;
397383 // subtree of the move I chose
398384 const subtree1 = data [ 2 ] . tree . find ( ( e ) =>
@@ -431,13 +417,6 @@ function mergePublicExploration(game, exploration, data) {
431417 const move = m . move ;
432418 const tree = m . tree ;
433419 let node = exploration [ move - 1 ] ;
434- // rehydrate state if needed
435- if ( node . state === null ) {
436- let tmpEngine = GameFactory ( game . metaGame , game . state ) ;
437- tmpEngine . stack = tmpEngine . stack . slice ( 0 , move + 1 ) ;
438- tmpEngine . load ( ) ;
439- node . state = tmpEngine . cheapSerialize ( ) ;
440- }
441420 node . version = version ;
442421 node . comment = m . tree . comment ;
443422 let gameEngine = GameFactory ( game . metaGame , node . state ) ;
@@ -460,13 +439,6 @@ function mergePrivateExploration(
460439 const move = m . move ;
461440 const tree = m . tree ;
462441 let node = exploration [ move - 1 ] ;
463- // rehydrate state if needed
464- if ( node . state === null ) {
465- let tmpEngine = GameFactory ( game . metaGame , game . state ) ;
466- tmpEngine . stack = tmpEngine . stack . slice ( 0 , move + 1 ) ;
467- tmpEngine . load ( ) ;
468- node . state = tmpEngine . cheapSerialize ( ) ;
469- }
470442 if ( version ) node . version = version ;
471443 let gameEngine = GameFactory ( game . metaGame , node . state ) ;
472444 const added = mergeMoveRecursive2 (
@@ -729,13 +701,6 @@ async function saveExploration(
729701 const move = data . sk ;
730702 const tree = JSON . parse ( data . tree ) ;
731703 let node = exploration [ move - 1 ] ;
732- // rehydrate state if needed
733- if ( node . state === null ) {
734- let tmpEngine = GameFactory ( game . metaGame , game . state ) ;
735- tmpEngine . stack = tmpEngine . stack . slice ( 0 , move + 1 ) ;
736- tmpEngine . load ( ) ;
737- node . state = tmpEngine . cheapSerialize ( ) ;
738- }
739704 node . version = version ;
740705 if ( tree . comment !== undefined )
741706 for ( const comment of tree . comment ) node . AddComment ( comment ) ;
@@ -783,13 +748,6 @@ function doView(
783748 navigate
784749) {
785750 let node = getFocusNode ( exploration , focus ) ;
786- // rehydrate state if needed
787- if ( node . state === null ) {
788- let tmpEngine = GameFactory ( game . metaGame , game . state ) ;
789- tmpEngine . stack = tmpEngine . stack . slice ( 0 , focus . moveNumber + 1 ) ;
790- tmpEngine . load ( ) ;
791- node . state = tmpEngine . cheapSerialize ( ) ;
792- }
793751 let gameEngineTmp = GameFactory ( game . metaGame , node . state ) ;
794752 let partialMove = false ;
795753 if ( move . valid && move . complete < 1 && move . canrender === true )
@@ -1065,13 +1023,6 @@ function processNewMove(
10651023 ! newmove . move . startsWith ( newmove . rendered )
10661024 ) {
10671025 let node = getFocusNode ( exploration , focus ) ;
1068- // rehydrate state if needed
1069- if ( node . state === null ) {
1070- let tmpEngine = GameFactory ( gameRef . current . metaGame , gameRef . current . state ) ;
1071- tmpEngine . stack = tmpEngine . stack . slice ( 0 , focus . moveNumber + 1 ) ;
1072- tmpEngine . load ( ) ;
1073- node . state = tmpEngine . cheapSerialize ( ) ;
1074- }
10751026 let gameEngineTmp = GameFactory ( gameRef . current . metaGame , node . state ) ;
10761027 partialMoveRenderRef . current = false ;
10771028 setStatus ( gameEngineTmp , gameRef . current , false , "" , statusRef . current ) ;
@@ -1995,16 +1946,9 @@ function GameMove(props) {
19951946 nodeidParam ,
19961947 ] ) ;
19971948
1998- const handlePlaygroundExport = async ( state , moveNumber ) => {
1949+ const handlePlaygroundExport = async ( state ) => {
19991950 const usr = await Auth . currentAuthenticatedUser ( ) ;
20001951 console . log ( "currentAuthenticatedUser" , usr ) ;
2001- // rehydrate state if needed
2002- if ( state === null ) {
2003- let tmpEngine = GameFactory ( game . metaGame , game . state ) ;
2004- tmpEngine . stack = tmpEngine . stack . slice ( 0 , moveNumber + 1 ) ;
2005- tmpEngine . load ( ) ;
2006- state = tmpEngine . cheapSerialize ( ) ;
2007- }
20081952 const res = await fetch ( API_ENDPOINT_AUTH , {
20091953 method : "POST" ,
20101954 headers : {
@@ -2155,13 +2099,6 @@ function GameMove(props) {
21552099 // handler when user types a move, selects a move (from list of available moves) or clicks on his stash.
21562100 const handleMove = ( value ) => {
21572101 let node = getFocusNode ( explorationRef . current . nodes , focus ) ;
2158- // rehydrate state if needed
2159- if ( node . state === null ) {
2160- let tmpEngine = GameFactory ( game . metaGame , game . state ) ;
2161- tmpEngine . stack = tmpEngine . stack . slice ( 0 , focus . moveNumber + 1 ) ;
2162- tmpEngine . load ( ) ;
2163- node . state = tmpEngine . cheapSerialize ( ) ;
2164- }
21652102 let gameEngineTmp = GameFactory ( gameRef . current . metaGame , node . state ) ;
21662103 let result ;
21672104 if ( gameRef . current . simultaneous )
@@ -2239,13 +2176,6 @@ function GameMove(props) {
22392176 function boardClick ( row , col , piece ) {
22402177 // console.log(`boardClick:(${row},${col},${piece})`);
22412178 let node = getFocusNode ( explorationRef . current . nodes , focusRef . current ) ;
2242- // rehydrate state if needed
2243- if ( node . state === null ) {
2244- let tmpEngine = GameFactory ( game . metaGame , game . state ) ;
2245- tmpEngine . stack = tmpEngine . stack . slice ( 0 , focusRef . current . moveNumber + 1 ) ;
2246- tmpEngine . load ( ) ;
2247- node . state = tmpEngine . cheapSerialize ( ) ;
2248- }
22492179 let gameEngineTmp = GameFactory ( gameRef . current . metaGame , node . state ) ;
22502180 let result = gameRef . current . simultaneous
22512181 ? gameEngineTmp . handleClickSimultaneous (
@@ -2888,13 +2818,6 @@ function GameMove(props) {
28882818 ( game . canSubmit || ( ! game . simultaneous && game . numPlayers === 2 ) )
28892819 ) {
28902820 let node = getFocusNode ( explorationRef . current . nodes , focus ) ;
2891- // rehydrate state if needed
2892- if ( node . state === null ) {
2893- let tmpEngine = GameFactory ( game . metaGame , game . state ) ;
2894- tmpEngine . stack = tmpEngine . stack . slice ( 0 , focus . moveNumber + 1 ) ;
2895- tmpEngine . load ( ) ;
2896- node . state = tmpEngine . cheapSerialize ( ) ;
2897- }
28982821 const engine = GameFactory ( game . metaGame , node . state ) ;
28992822 if ( game . simultaneous ) movesRef . current = engine . moves ( game . me + 1 ) ;
29002823 else movesRef . current = engine . moves ( ) ;
0 commit comments