Changeset 524
- Timestamp:
- 04/27/08 13:11:16 (9 months ago)
- Files:
-
- trunk/src/defend/Camera.d (modified) (1 diff)
- trunk/src/defend/game/hud/Hud.d (modified) (1 diff)
- trunk/src/defend/game/hud/Mouse.d (modified) (2 diffs)
- trunk/src/defend/game/net/Client.d (modified) (2 diffs)
- trunk/src/defend/game/net/Server.d (modified) (6 diffs)
- trunk/src/defend/objects/Core.d (modified) (1 diff)
- trunk/src/defend/objects/types/Building.d (modified) (3 diffs)
- trunk/src/defend/objects/types/Unit.d (modified) (2 diffs)
- trunk/src/gen/list/SyncQueue.d (modified) (1 diff)
- trunk/src/gen/math/Vector.d (modified) (1 diff)
- trunk/src/gen/net/tcp/Message.d (modified) (1 diff)
- trunk/src/gen/net/tcp/Socket.d (modified) (3 diffs)
- trunk/src/gen/scene/ParticleSystem.d (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/defend/Camera.d
r473 r524 83 83 minDistance -= inputSpeed(input); 84 84 85 if(minDistance < 1)86 minDistance = 1;85 if(minDistance < 2.5) 86 minDistance = 2.5; 87 87 } 88 88 trunk/src/defend/game/hud/Hud.d
r519 r524 118 118 }); 119 119 120 debugforeach(obj; mouse.selection)120 version(none) foreach(obj; mouse.selection) 121 121 { 122 122 auto p = mouse.getScreenPos(obj.realPos); trunk/src/defend/game/hud/Mouse.d
r522 r524 347 347 vec2i(terrain.dimension.x, 348 348 terrain.dimension.y)); 349 349 350 350 gameObjects.order(gameObjects.gateway, selection, 351 351 OrderMapRightClick(cast(ushort)translated.x, … … 371 371 if(target is null) 372 372 { 373 // tmp :D 374 //for(uint i = 0; i < 100; i++) 373 375 gameObjects.order(gameObjects.gateway, selection, 374 376 OrderMapRightClick(mapPos.x, mapPos.y)); trunk/src/defend/game/net/Client.d
r483 r524 73 73 74 74 MessagePong messageOut; 75 socket.send(messageOut); 75 socket.send(messageOut); 76 77 //logger.trace("sending pong"); 76 78 } 77 79 … … 357 359 phaseQueue.first.simulationSteps); 358 360 361 debug if(phaseQueue.first.whichPhase % 30 == 0) 362 logger.trace("phase length: {}", phaseQueue.first.length); 363 359 364 StartPhase(phaseQueue.first); 360 365 trunk/src/defend/game/net/Server.d
r519 r524 102 102 } 103 103 104 uint last = 0;104 uint lastPing = 0; 105 105 while(!socket.stop) 106 106 { 107 if(server.gameStarted && getTickCount() - last > 1000&&108 pingAnswer)107 if(server.gameStarted && getTickCount() - lastPing > 1000 //&& 108 /*pingAnswer*/) 109 109 { 110 if(!pingAnswer) 111 { 112 logger.warn("no pong in 1 second"); 113 114 // man, wtf 115 Thread.sleep(2); 116 } 117 118 //logger.trace("sending ping"); 119 110 120 MessagePing message; 111 121 socket.send(message); … … 113 123 pingAnswer = false; 114 124 pingSend = getTickCount(); 115 last = getTickCount();125 lastPing = getTickCount(); 116 126 } 117 127 118 128 Thread.yield(); 119 129 } 130 131 //logger.trace("thread's done for"); 120 132 } 121 133 catch(Exception exception) … … 161 173 lastHighestPing = pingLast; 162 174 163 debug(networking) if(pingCount == 0) 164 logger.info("ping: {}", pingLast); 165 166 pingCount++; 167 168 if(pingCount == 5) 175 /*debug(networking)*/ //if(pingCount == 0) 176 // logger.info("ping: {}", pingLast); 177 178 if(++pingCount == 5) 169 179 pingCount = 0; 170 180 } … … 187 197 message.patch != DEFEND_VERSION_PATCH) 188 198 { 189 // FIX: What should we do in this case?199 // TODO: What should we do in this case? 190 200 logger.warn("version unknown"); 191 201 } … … 561 571 } 562 572 563 const uint MIN_PHASE_LENGTH = 200;573 const uint MIN_PHASE_LENGTH = 100; 564 574 const uint MAX_PHASE_LENGTH = 1000; 565 575 const uint SIMULATION_STEPS_PER_SECOND = 50; … … 684 694 685 695 stop = true; 686 Thread.join();696 join(); 687 697 688 698 foreach(client; cm) trunk/src/defend/objects/Core.d
r522 r524 846 846 final MapPos searchFreeTileAround(MapPos from) 847 847 { 848 const uint radius = 1;849 assert(radius >= 1);850 851 848 bool hasResult = false; 852 849 float minDistance; trunk/src/defend/objects/types/Building.d
r521 r524 577 577 super.onRemove(); 578 578 579 //void spawn(vec3 point, uint number)580 581 579 foreach(x, y; mapRectangle) 582 particles("smoke").spawn(terrain.getWorldPos(x, y) + vec3(0, 0.5, 1), 1);580 particles("smoke").spawn(terrain.getWorldPos(x, y) + vec3(0, 1.5, 1), 1); 583 581 584 582 markMap(true); … … 590 588 if(selected && buildTarget != mapPos) 591 589 { 592 glLineWidth( 3);590 glLineWidth(2); 593 591 renderer.setRenderState(RenderState.DepthTest, false); 594 592 … … 634 632 635 633 auto obj = cast(Unit)gameObjects.localCreate(owner, 636 entry.unitType.objectType,637 unitPos.x,638 unitPos.y);634 entry.unitType.objectType, 635 unitPos.x, 636 unitPos.y); 639 637 640 638 assert(obj !is null); trunk/src/defend/objects/types/Unit.d
r521 r524 265 265 { 266 266 pause = 3; 267 path = [];267 path = null; 268 268 269 269 moveFinished(); … … 668 668 { 669 669 // Debug the path 670 debug if(selected && moving && path.length)670 debug(unit) if(selected && moving && path.length) 671 671 { 672 672 MapPos a = mapPos; trunk/src/gen/list/SyncQueue.d
r401 r524 39 39 result = queue.empty; 40 40 41 return result; 42 } 43 44 uint length() 45 { 46 uint result; 47 48 synchronized(mutex) 49 result = queue.length; 50 41 51 return result; 42 52 } trunk/src/gen/math/Vector.d
r501 r524 312 312 } 313 313 314 Vec3 normalized( float n = 1)315 { 316 return *this * cast(T)(1 / (length() / n));314 Vec3 normalized() 315 { 316 return *this * cast(T)(1 / length()); 317 317 } 318 318 trunk/src/gen/net/tcp/Message.d
r506 r524 28 28 message_type_t*[char[]] messageTypes; 29 29 30 char[] getMessageTypeName(message_type_t type) 31 { 32 foreach(key, val; messageTypes) 33 if(*val == type) 34 return key; 35 36 assert(false); 37 } 38 30 39 // will remain until I write the message's length at the beginning of it 31 40 ubyte[] messageSeparator = ['\r', '\n', 255, 254, 253]; trunk/src/gen/net/tcp/Socket.d
r509 r524 141 141 //Trace.formatln("message: {}", line.length); 142 142 143 // debug 144 //auto name = getMessageTypeName(*(cast(message_type_t*)line[0 .. message_type_t.sizeof])); 145 146 //if(name == "MessagePing " || name == "MessagePong ") 147 // logger.trace("<= {}", name); 148 143 149 handleMessage(line); 144 150 … … 168 174 if(!writeQueue.poll(0.5, message)) 169 175 continue; 176 177 // debug 178 //auto name = getMessageTypeName(*(cast(message_type_t*)message.data[0 .. message_type_t.sizeof])); 179 180 //if(name == "MessagePing " || name == "MessagePong ") 181 // logger.trace("=> {}", name); 182 183 //logger.trace("REMAIN: {}", writeQueue.length); 170 184 171 185 assert(message !is null, "message is null"); … … 193 207 } 194 208 195 assert(sent <= remain, "w tf");209 assert(sent <= remain, "wft"); 196 210 remain -= sent; 197 211 } trunk/src/gen/scene/ParticleSystem.d
r501 r524 97 97 velocity = vec3(random!(float)(-1, 1), random!(float)(-1, 1), random!(float)(-1, 1)); 98 98 velocity *= 3; 99 velocity = velocity.normalized( 0.2);99 velocity = velocity.normalized() * 0.2; 100 100 101 101 color = vec4(1, 1, 1, 0.5 + 0.5 * random!(float)(0, 1)); … … 112 112 position += velocity * time; 113 113 114 color.a -= 0. 1* time;114 color.a -= 0.045 * time; 115 115 size += 0.1 * time; 116 116 velocity -= velocity * time * 0.2f;
