WARP.CPP 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. #include "db.h"
  2. #include "engine.h"
  3. #include "globals.h"
  4. #include "options.h"
  5. #include "warp.h"
  6. #include "error.h"
  7. #include "debug4g.h"
  8. /***********************************************************************
  9. * Global Data
  10. **********************************************************************/
  11. ZONE gStartZone[kMaxPlayers];
  12. short gUpperLink[kMaxSectors], gLowerLink[kMaxSectors];
  13. /***********************************************************************
  14. * InitPlayerStartZones()
  15. *
  16. **********************************************************************/
  17. void InitPlayerStartZones( void )
  18. {
  19. int nSprite, nXSprite;
  20. // clear link values
  21. for ( int nSector = 0; nSector < kMaxSectors; nSector++ )
  22. {
  23. gUpperLink[nSector] = -1;
  24. gLowerLink[nSector] = -1;
  25. }
  26. for ( nSprite = 0; nSprite < kMaxSprites; nSprite++ )
  27. {
  28. if (sprite[nSprite].statnum < kMaxStatus)
  29. {
  30. SPRITE *pSprite = &sprite[nSprite];
  31. nXSprite = pSprite->extra;
  32. if ( nXSprite > 0 )
  33. {
  34. XSPRITE *pXSprite = &xsprite[nXSprite];
  35. switch( pSprite->type )
  36. {
  37. case kMarkerPlayerStart:
  38. {
  39. if ( (gNetMode == kNetModeOff || gNetMode == kNetModeCoop)
  40. && (pXSprite->data1 >= 0 && pXSprite->data1 < kMaxPlayers) )
  41. {
  42. ZONE *pZone = &gStartZone[pXSprite->data1];
  43. pZone->x = pSprite->x;
  44. pZone->y = pSprite->y;
  45. pZone->z = pSprite->z;
  46. pZone->sector = pSprite->sectnum;
  47. pZone->angle = pSprite->ang;
  48. }
  49. deletesprite( (short)nSprite );
  50. break;
  51. }
  52. case kMarkerDeathStart:
  53. if ( gNetMode == kNetModeBloodBath
  54. && (pXSprite->data1 >= 0 && pXSprite->data1 < kMaxPlayers) )
  55. {
  56. ZONE *pZone = &gStartZone[pXSprite->data1];
  57. pZone->x = pSprite->x;
  58. pZone->y = pSprite->y;
  59. pZone->z = pSprite->z;
  60. pZone->sector = pSprite->sectnum;
  61. pZone->angle = pSprite->ang;
  62. }
  63. deletesprite( (short)nSprite );
  64. break;
  65. case kMarkerUpperLink:
  66. gUpperLink[pSprite->sectnum] = (short)nSprite;
  67. pSprite->cstat |= kSpriteInvisible | kSpriteMapNever;
  68. pSprite->cstat &= ~kSpriteBlocking & ~kSpriteHitscan;
  69. break;
  70. case kMarkerLowerLink:
  71. gLowerLink[pSprite->sectnum] = (short)nSprite;
  72. pSprite->cstat |= kSpriteInvisible | kSpriteMapNever;
  73. pSprite->cstat &= ~kSpriteBlocking & ~kSpriteHitscan;
  74. break;
  75. }
  76. }
  77. }
  78. }
  79. // verify links have mates and connect them
  80. for (int nFrom = 0; nFrom < kMaxSectors; nFrom++)
  81. {
  82. if ( gUpperLink[nFrom] >= 0 )
  83. {
  84. SPRITE *pFromSprite = &sprite[gUpperLink[nFrom]];
  85. nXSprite = pFromSprite->extra;
  86. dassert(nXSprite > 0 && nXSprite < kMaxXSprites);
  87. XSPRITE *pXSprite = &xsprite[nXSprite];
  88. int nID = pXSprite->data1;
  89. for (int nTo = 0; nTo < kMaxSectors; nTo++)
  90. {
  91. if ( gLowerLink[nTo] >= 0 )
  92. {
  93. SPRITE *pToSprite = &sprite[gLowerLink[nTo]];
  94. nXSprite = pToSprite->extra;
  95. dassert(nXSprite > 0 && nXSprite < kMaxXSprites);
  96. XSPRITE *pXSprite = &xsprite[nXSprite];
  97. if ( pXSprite->data1 == nID )
  98. {
  99. pFromSprite->owner = (short)gLowerLink[nTo];
  100. pToSprite->owner = (short)gUpperLink[nFrom];
  101. }
  102. }
  103. }
  104. }
  105. }
  106. }