403 :(ShipEntity*)ship
404{
405 int corridor_distance[] = { -1, 1, 3, 5, 7, 9, 11, 12, 12 };
406 int corridor_offset[] = { 0, 0, 0, 0, 0, 0, 1, 3, 12 };
407
408
409
410
411
412 int corridor_speed[] = { 96, 96, 128, 128, 96, 128, 128, 256, 512 };
413 int corridor_range[] = { 24, 12, 6, 4, 4, 6, 15, 38, 96 };
414 int corridor_rotate[] = { 1, 1, 1, 1, 0, 0, 0, 0, 0 };
415 int corridor_count = 9;
416 int corridor_final_approach = 3;
417
418 NSNumber* shipID = [NSNumber numberWithUnsignedShort:[ship
universalID]];
419 StationEntity* station = (StationEntity*)[self parentEntity];
420
426
427
431
432
433 HPVector point1 = [
self absolutePositionForSubentity];
434 point1.
x += launchVector.
x * corridor_offset[corridor_count - 1];
435 point1.
y += launchVector.
x * corridor_offset[corridor_count - 1];
436 point1.
z += launchVector.
x * corridor_offset[corridor_count - 1];
438 point1.
x += c * upVector.
x * corridor_offset[corridor_count - 1] + s * rightVector.
x * corridor_offset[corridor_count - 1];
439 point1.
y += c * upVector.
y * corridor_offset[corridor_count - 1] + s * rightVector.
y * corridor_offset[corridor_count - 1];
440 point1.
z += c * upVector.z * corridor_offset[corridor_count - 1] + s * rightVector.z * corridor_offset[corridor_count - 1];
441 alt1.
x -= c * upVector.
x * corridor_offset[corridor_count - 1] + s * rightVector.
x * corridor_offset[corridor_count - 1];
442 alt1.
y -= c * upVector.
y * corridor_offset[corridor_count - 1] + s * rightVector.
y * corridor_offset[corridor_count - 1];
443 alt1.
z -= c * upVector.z * corridor_offset[corridor_count - 1] + s * rightVector.z * corridor_offset[corridor_count - 1];
445 s = -s;
446 c = -c;
447 }
448
449
450 NSMutableArray* coordinatesStack = [NSMutableArray arrayWithCapacity:MAX_DOCKING_STAGES];
451 float port_depth = port_dimensions.
z;
452
453 int i;
454 for (i = corridor_count - 1; i >= 0; i--) {
455 NSMutableDictionary* nextCoords = [NSMutableDictionary dictionaryWithCapacity:3];
456 int offset = corridor_offset[i];
457 float corridor_length = port_depth * corridor_distance[i];
458
459 float rx = s * port_depth *
offset;
460 float ry = c * port_depth *
offset;
461 float rz = corridor_length;
462
463 if ((i == corridor_count - 1) && [self countOfShipsInDockingQueue]) {
464
465
466
467
468
469
470
471
472
473
474
475
476
481 float ssize =
MAX(port_depth, 1500.0);
482 rx += c2 * ssize;
483 ry += s2 * ssize;
484 rz += ssize * ((float)offset_id3 / 4.0);
485
486
487 }
488
489
490 if (corridor_distance[i] > 0)
491 corridor_length += port_corridor;
492
493 [nextCoords oo_setInteger:corridor_count - i forKey:@"docking_stage"];
494 [nextCoords oo_setFloat:rx forKey:@"rx"];
495 [nextCoords oo_setFloat:ry forKey:@"ry"];
496 [nextCoords oo_setFloat:rz forKey:@"rz"];
497 [nextCoords oo_setFloat:corridor_speed[i] forKey:@"speed"];
498 [nextCoords oo_setFloat:corridor_range[i] forKey:@"range"];
499
500 if (corridor_rotate[i]) {
501 [nextCoords setObject:@"YES" forKey:@"match_rotation"];
502 }
503
504 if (i == corridor_final_approach) {
505 if (station == [
UNIVERSE station]) {
506 [nextCoords setObject:@"[station-begin-final-aproach]" forKey:@"comms_message"];
507 } else {
508 [nextCoords setObject:@"[docking-begin-final-aproach]" forKey:@"comms_message"];
509 }
510 }
511
512 [coordinatesStack addObject:nextCoords];
513 }
514
515 [shipsOnApproach setObject:coordinatesStack forKey:shipID];
516
517
518 if (station == [
UNIVERSE station]) {
519 [station sendExpandedMessage:@"[station-welcome]" toShip:ship];
520 } else {
521 [station sendExpandedMessage:@"[docking-welcome]" toShip:ship];
522 }
523}
OOINLINE HPVector HPcross_product(HPVector first, HPVector second) INLINE_CONST_FUNC
OOINLINE HPVector make_HPvector(OOHPScalar vx, OOHPScalar vy, OOHPScalar vz) INLINE_CONST_FUNC
OOINLINE OOHPScalar HPdistance2(HPVector v1, HPVector v2) INLINE_CONST_FUNC
Quaternion quaternion_multiply(Quaternion q1, Quaternion q2) CONST_FUNC
HPVector HPvector_forward_from_quaternion(Quaternion quat) CONST_FUNC
OOUniversalID universalID
GLint entityPersonalityInt()