446{
447 int corridor_distance[] = { -1, 1, 3, 5, 7, 9, 11, 12, 12};
448 int corridor_offset[] = { 0, 0, 0, 0, 0, 0, 1, 3, 12};
449
450
451
452
453
454 int corridor_speed[] = { 96, 96, 128, 128, 96, 128, 128, 256, 512};
455 int corridor_range[] = { 24, 12, 6, 4, 4, 6, 15, 38, 96};
456 int corridor_rotate[] = { 1, 1, 1, 1, 0, 0, 0, 0, 0};
457 int corridor_count = 9;
458 int corridor_final_approach = 3;
459
460 NSNumber *shipID = [NSNumber numberWithUnsignedShort:[ship
universalID]];
462
464 HPVector temp = (fabs(launchVector.x) < 0.8)? make_HPvector(1,0,0) : make_HPvector(0,1,0);
465 temp = HPcross_product(launchVector, temp);
466 HPVector rightVector = HPcross_product(launchVector, temp);
467 HPVector upVector = HPcross_product(launchVector, rightVector);
468
469
473
474
475 HPVector point1 = [self absolutePositionForSubentity];
476 point1.x += launchVector.
x * corridor_offset[corridor_count - 1];
477 point1.y += launchVector.
x * corridor_offset[corridor_count - 1];
478 point1.z += launchVector.
x * corridor_offset[corridor_count - 1];
479 HPVector alt1 = point1;
480 point1.x += c * upVector.
x * corridor_offset[corridor_count - 1] + s * rightVector.
x * corridor_offset[corridor_count - 1];
481 point1.y += c * upVector.
y * corridor_offset[corridor_count - 1] + s * rightVector.
y * corridor_offset[corridor_count - 1];
482 point1.z += c * upVector.z * corridor_offset[corridor_count - 1] + s * rightVector.z * corridor_offset[corridor_count - 1];
483 alt1.x -= c * upVector.
x * corridor_offset[corridor_count - 1] + s * rightVector.
x * corridor_offset[corridor_count - 1];
484 alt1.y -= c * upVector.
y * corridor_offset[corridor_count - 1] + s * rightVector.
y * corridor_offset[corridor_count - 1];
485 alt1.z -= c * upVector.z * corridor_offset[corridor_count - 1] + s * rightVector.z * corridor_offset[corridor_count - 1];
486 if (HPdistance2(alt1, ship->
position) < HPdistance2(point1, ship->
position))
487 {
488 s = -s;
489 c = -c;
490 }
491
492
493 NSMutableArray *coordinatesStack = [NSMutableArray arrayWithCapacity: MAX_DOCKING_STAGES];
494 float port_depth = port_dimensions.z;
495
496 int i;
497 for (i = corridor_count - 1; i >= 0; i--)
498 {
499 NSMutableDictionary *nextCoords = [NSMutableDictionary dictionaryWithCapacity:3];
500 int offset = corridor_offset[i];
501 float corridor_length = port_depth * corridor_distance[i];
502
503 float rx = s * port_depth *
offset;
504 float ry = c * port_depth *
offset;
505 float rz = corridor_length;
506
507 if ((i == corridor_count - 1) && [self countOfShipsInDockingQueue])
508 {
509
510
511
512
513
514
515
516
517
518
519
520
521
526 float ssize =
MAX(port_depth,1500.0);
527 rx += c2 * ssize;
528 ry += s2 * ssize;
529 rz += ssize * ((float)offset_id3 / 4.0);
530
531
532 }
533
534
535 if (corridor_distance[i] > 0) corridor_length += port_corridor;
536
537 [nextCoords oo_setInteger:corridor_count - i forKey:@"docking_stage"];
538 [nextCoords oo_setFloat:rx forKey:@"rx"];
539 [nextCoords oo_setFloat:ry forKey:@"ry"];
540 [nextCoords oo_setFloat:rz forKey:@"rz"];
541 [nextCoords oo_setFloat:corridor_speed[i] forKey:@"speed"];
542 [nextCoords oo_setFloat:corridor_range[i] forKey:@"range"];
543
544 if (corridor_rotate[i])
545 {
546 [nextCoords setObject:@"YES" forKey:@"match_rotation"];
547 }
548
549 if (i == corridor_final_approach)
550 {
552 {
553 [nextCoords setObject:@"[station-begin-final-aproach]" forKey:@"comms_message"];
554 }
555 else
556 {
557 [nextCoords setObject:@"[docking-begin-final-aproach]" forKey:@"comms_message"];
558 }
559 }
560
561 [coordinatesStack addObject:nextCoords];
562 }
563
564 [shipsOnApproach setObject:coordinatesStack forKey:shipID];
565
566
567
569 {
570 [station sendExpandedMessage:@"[station-welcome]" toShip:ship];
571 }
572 else
573 {
574 [station sendExpandedMessage:@"[docking-welcome]" toShip:ship];
575 }
576}
HPVector HPvector_forward_from_quaternion(Quaternion quat)
Quaternion quaternion_multiply(Quaternion q1, Quaternion q2)
OOUniversalID universalID
GLint entityPersonalityInt()